/*
  Program Name:  MC_Slave
  Project:       LLH Hopscotch
  Written By:    Daniel Lee
  Revision:      0.6.1
  Change log:   Minor fixes
    Fixed a problem where the controller locks on to a channel and never receives a valid signal.
    Fixed an unresolved situation during AUTO mode when the path reached a dead-end.
    Fixed a problem that occurs during testing when a board already has an ID higher than next_available_ID
*/

#include<SoftwareSerial.h>
#include<PCM.h>


// Pins 2 and 7 are reserved for FTDI comms
// Pins 0 and 1 are reserved for USB comms (during programming only)

#define TRXRATE 19200
#define TERMBAUD 9600
#define LEDPIN 3 //Pin that controls the LEDs
#define SENSORPIN A5 //Pin that reads the pressure sensor input
#define SPKRPIN 11 //Pin that controls the speaker output
#define SEEDPIN A1
#define RX_1 4
#define TX_1 5
#define RX_2 6
#define TX_2 8
#define RX_3 9
#define TX_3 10
#define RX_4 12
#define TX_4 13
#define MAX_BUFFER_SIZE 64
#define TIME_OUT 25
#define PLAYTIME 3000
#define LOCKTIME 1000
#define NO_RESPONSE 160

//STATE CODES:
#define LISTENING 0
#define CHANNEL_SET 1
#define PROCESS_MSG 2

//COMMAND CODES:
#define COM 170
#define ROGER 171
#define NEGATIVE 172
#define SETID 173
#define SENDID 174
#define SETNEIGHBORS 175
#define IDSET 176
#define NEIGHBORSSET 177
#define AUTO 200
#define NOCOM 255

const unsigned char happy_data[] PROGMEM = {129, 
134, 151, 175, 201, 216, 214, 194, 162, 128, 101, 85, 81, 81, 80, 76, 70, 67, 75, 94, 123, 
156, 184, 200, 203, 194, 181, 167, 157, 147, 136, 120, 98, 76, 57, 49, 53, 70, 99, 139, 184, 
226, 251, 255, 242, 216, 187, 158, 133, 110, 85, 58, 31, 11, 5, 17, 47, 86, 128, 166, 193, 
211, 222, 226, 228, 222, 208, 181, 145, 104, 64, 34, 18, 16, 26, 45, 66, 90, 118, 148, 180, 
210, 232, 243, 239, 221, 192, 158, 124, 93, 67, 47, 33, 26, 26, 37, 60, 92, 129, 167, 199, 
220, 231, 230, 220, 205, 183, 156, 125, 93, 62, 37, 23, 20, 30, 52, 81, 113, 144, 173, 197, 
215, 226, 228, 220, 202, 174, 141, 106, 74, 49, 34, 28, 32, 45, 66, 92, 123, 155, 184, 209, 
225, 231, 225, 208, 181, 151, 120, 89, 63, 44, 32, 30, 38, 55, 80, 113, 146, 177, 203, 219, 
226, 223, 210, 189, 162, 132, 100, 72, 48, 34, 29, 36, 52, 77, 108, 140, 170, 195, 213, 222, 
222, 211, 192, 167, 136, 104, 75, 52, 37, 32, 38, 53, 78, 106, 137, 166, 192, 211, 221, 221, 
211, 192, 166, 134, 103, 75, 53, 39, 35, 41, 56, 79, 107, 138, 168, 193, 212, 221, 220, 208, 
187, 159, 128, 97, 71, 50, 39, 37, 45, 62, 87, 115, 146, 175, 199, 214, 220, 215, 200, 178, 
149, 119, 90, 65, 47, 38, 39, 51, 71, 98, 129, 160, 187, 206, 217, 216, 206, 188, 163, 134, 
104, 77, 56, 42, 39, 45, 63, 87, 117, 147, 176, 198, 212, 217, 211, 196, 173, 143, 113, 84, 
61, 46, 40, 45, 59, 82, 110, 140, 168, 192, 208, 215, 211, 198, 176, 149, 118, 90, 65, 48, 
41, 44, 58, 81, 108, 138, 167, 191, 207, 213, 209, 196, 175, 148, 119, 90, 66, 49, 42, 46, 
60, 83, 111, 141, 169, 192, 207, 212, 208, 193, 170, 141, 109, 76, 50, 34, 32, 43, 67, 100, 
136, 170, 198, 217, 224, 219, 203, 177, 144, 107, 73, 44, 28, 25, 37, 63, 97, 135, 172, 204, 
224, 232, 224, 203, 170, 130, 87, 52, 29, 22, 31, 53, 86, 125, 163, 196, 219, 230, 226, 208, 
178, 139, 99, 63, 36, 23, 27, 46, 78, 117, 157, 193, 219, 230, 227, 208, 177, 140, 101, 65, 
40, 27, 29, 48, 78, 116, 156, 192, 218, 230, 225, 206, 176, 138, 98, 63, 38, 27, 32, 51, 
83, 122, 163, 198, 221, 229, 221, 199, 167, 127, 89, 57, 36, 28, 36, 59, 94, 135, 174, 206, 
226, 229, 215, 188, 150, 111, 74, 46, 31, 32, 47, 76, 114, 154, 190, 216, 227, 223, 202, 169, 
130, 90, 57, 35, 29, 39, 64, 100, 141, 179, 209, 225, 225, 207, 177, 140, 100, 65, 41, 31, 
37, 59, 92, 132, 172, 205, 224, 226, 211, 181, 143, 103, 67, 42, 32, 37, 59, 92, 132, 171, 
203, 222, 224, 210, 181, 143, 102, 65, 40, 31, 39, 63, 98, 139, 178, 208, 223, 221, 202, 171, 
133, 93, 59, 38, 33, 44, 72, 109, 150, 188, 215, 225, 217, 192, 156, 115, 77, 48, 34, 37, 
57, 90, 129, 168, 201, 220, 222, 206, 175, 136, 95, 60, 38, 33, 46, 76, 115, 157, 193, 216, 
222, 211, 183, 145, 105, 69, 44, 35, 43, 68, 106, 147, 185, 213, 223, 215, 189, 150, 108, 70, 
44, 35, 44, 69, 106, 148, 184, 210, 220, 212, 187, 151, 109, 71, 44, 34, 44, 71, 110, 153, 
191, 216, 222, 208, 178, 138, 97, 62, 42, 38, 53, 83, 122, 163, 197, 218, 219, 201, 166, 124, 
82, 51, 35, 41, 65, 102, 145, 183, 209, 218, 208, 181, 143, 102, 66, 44, 38, 53, 83, 124, 
168, 202, 220, 217, 193, 155, 111, 71, 44, 37, 50, 80, 120, 161, 194, 213, 213, 195, 163, 121, 
81, 51, 38, 46, 72, 112, 158, 196, 218, 218, 196, 159, 115, 75, 47, 40, 52, 81, 121, 162, 
194, 213, 211, 191, 156, 113, 74, 47, 39, 52, 84, 128, 172, 206, 220, 211, 181, 138, 94, 58, 
39, 43, 67, 105, 149, 187, 211, 215, 198, 165, 122, 79, 48, 36, 48, 80, 125, 171, 208, 223, 
214, 182, 135, 87, 50, 34, 42, 73, 116, 163, 201, 219, 214, 187, 146, 100, 61, 38, 39, 62, 
103, 152, 192, 212, 207, 184, 155, 130, 115, 113, 118, 126, 134, 138, 142, 146, 148, 146, 135, 114, 
87, 62, 47, 50, 73, 110, 150, 177, 183, 171, 153, 143, 148, 167, 190, 202, 198, 175, 143, 114, 
96, 94, 101, 108, 107, 95, 77, 62, 57, 67, 88, 113, 134, 146, 149, 147, 148, 155, 169, 184, 
194, 194, 183, 165, 145, 130, 121, 116, 113, 106, 95, 81, 70, 64, 67, 78, 93, 109, 122, 131, 
137, 145, 154, 166, 178, 186, 189, 184, 175, 162, 148, 137, 128, 118, 108, 97, 85, 75, 69, 69, 
75, 85, 97, 109, 120, 131, 142, 153, 165, 175, 182, 185, 184, 177, 168, 156, 144, 132, 120, 108, 
96, 86, 77, 72, 71, 75, 83, 94, 106, 119, 132, 145, 157, 168, 177, 182, 184, 182, 176, 166, 
155, 141, 128, 114, 101, 90, 81, 74, 71, 73, 79, 88, 100, 114, 128, 142, 156, 167, 175, 181, 
183, 182, 177, 168, 157, 143, 128, 114, 100, 88, 79, 74, 72, 74, 80, 90, 102, 116, 132, 147, 
160, 171, 179, 183, 184, 180, 173, 163, 151, 136, 120, 105, 92, 81, 74, 71, 72, 78, 87, 99, 
113, 129, 145, 159, 171, 179, 184, 184, 180, 173, 163, 149, 134, 118, 102, 89, 78, 72, 70, 73, 
80, 91, 104, 120, 136, 152, 165, 176, 183, 185, 183, 177, 167, 154, 139, 122, 106, 92, 80, 72, 
70, 72, 78, 89, 103, 119, 136, 152, 166, 177, 184, 186, 183, 177, 166, 152, 135, 118, 102, 87, 
76, 70, 69, 73, 82, 95, 110, 128, 145, 161, 174, 182, 186, 185, 180, 169, 155, 139, 122, 104, 
89, 77, 70, 68, 72, 81, 94, 111, 128, 147, 163, 176, 184, 187, 185, 178, 167, 151, 134, 116, 
99, 83, 73, 68, 68, 75, 87, 102, 121, 139, 157, 171, 182, 187, 187, 181, 170, 156, 138, 119, 
101, 85, 73, 67, 68, 74, 86, 102, 121, 140, 158, 173, 183, 188, 187, 180, 166, 148, 127, 105, 
87, 74, 67, 67, 73, 86, 103, 122, 142, 162, 177, 187, 190, 186, 175, 157, 136, 113, 92, 76, 
66, 65, 72, 85, 103, 124, 145, 165, 180, 189, 191, 184, 170, 151, 129, 106, 86, 72, 65, 66, 
75, 91, 112, 135, 157, 175, 188, 191, 187, 175, 157, 136, 113, 92, 75, 66, 64, 72, 87, 108, 
132, 156, 176, 188, 192, 187, 175, 156, 134, 111, 90, 74, 65, 64, 73, 91, 114, 139, 163, 182, 
192, 192, 184, 167, 146, 123, 100, 81, 68, 63, 68, 82, 103, 129, 155, 177, 191, 195, 188, 172, 
150, 126, 102, 83, 69, 64, 68, 81, 102, 128, 155, 177, 191, 196, 188, 171, 148, 122, 97, 78, 
66, 63, 71, 87, 110, 137, 163, 184, 195, 194, 183, 162, 136, 109, 86, 69, 63, 66, 80, 102, 
128, 155, 178, 193, 196, 187, 168, 142, 114, 88, 69, 61, 64, 78, 101, 128, 155, 179, 193, 196, 
186, 166, 139, 110, 85, 66, 60, 65, 82, 107, 137, 164, 186, 196, 194, 180, 155, 127, 98, 75, 
61, 60, 72, 95, 124, 154, 179, 195, 198, 186, 163, 134, 104, 78, 62, 59, 69, 91, 120, 151, 
178, 195, 199, 188, 164, 133, 101, 75, 60, 58, 71, 95, 126, 158, 183, 197, 197, 183, 156, 124, 
92, 68, 56, 60, 78, 108, 141, 173, 195, 201, 192, 168, 136, 103, 75, 58, 57, 72, 98, 132, 
165, 190, 201, 196, 175, 144, 107, 76, 57, 54, 68, 97, 132, 167, 193, 203, 196, 172, 138, 102, 
73, 55, 55, 72, 103, 141, 175, 198, 205, 192, 164, 127, 89, 61, 51, 59, 85, 121, 159, 190, 
206, 201, 178, 142, 102, 69, 52, 53, 74, 109, 149, 185, 205, 205, 185, 149, 108, 72, 50, 49, 
70, 106, 149, 185, 206, 207, 185, 148, 106, 68, 47, 49, 72, 112, 156, 193, 212, 207, 179, 137, 
92, 57, 43, 53, 85, 129, 173, 204, 214, 198, 162, 115, 72, 45, 43, 65, 107, 156, 196, 218, 
210, 178, 130, 80, 46, 37, 56, 98, 149, 193, 219, 215, 184, 135, 83, 46, 35, 53, 95, 149, 
196, 223, 218, 184, 132, 76, 39, 31, 54, 103, 160, 207, 229, 216, 173, 116, 60, 29, 31, 66, 
123, 182, 223, 231, 204, 150, 88, 37, 20, 41, 92, 158, 213, 238, 224, 175, 109, 49, 16, 25, 
71, 138, 205, 242, 237, 198, 147, 106, 88, 91, 108, 129, 142, 149, 144, 134, 120, 106, 104, 116, 
135, 152, 159, 152, 135, 118, 110, 113, 126, 140, 147, 143, 129, 112, 102, 102, 114, 130, 143, 147, 
139, 126, 115, 113, 122, 137, 149, 154, 147, 133, 117, 109, 110, 119, 132, 139, 137, 128, 116, 108, 
109, 118, 132, 144, 148, 145, 135, 126, 121, 123, 130, 137, 141, 137, 128, 117, 110, 110, 116, 126, 
134, 136, 133, 127, 122, 122, 128, 136, 143, 146, 142, 133, 123, 117, 116, 120, 126, 130, 130, 126, 
120, 117, 117, 123, 131, 139, 143, 142, 138, 131, 127, 125, 127, 129, 131, 129, 124, 120, 116, 116, 
119, 125, 131, 134, 135, 134, 133, 132, 132, 134, 135, 134, 131, 126, 121, 118, 117, 119, 122, 126, 
128, 129, 128, 129, 130, 133, 137, 139, 139, 136, 130, 125, 121, 119, 120, 122, 124, 125, 125, 125, 
125, 127, 131, 135, 139, 140, 138, 134, 129, 124, 121, 120, 121, 123, 124, 124, 124, 124, 125, 129, 
132, 137, 139, 139, 136, 132, 127, 123, 122, 121, 122, 124, 124, 124, 124, 125, 127, 131, 135, 138, 
139, 138, 133, 129, 124, 121, 120, 121, 122, 124, 125, 125, 126, 128, 131, 134, 137, 138, 137, 133, 
128, 124, 121, 119, 121, 123, 125, 126, 127, 128, 129, 132, 134, 137, 138, 135, 131, 126, 121, 119, 
119, 121, 124, 127, 129, 130, 130, 131, 133, 135, 135, 135, 132, 127, 122, 119, 118, 120, 124, 128, 
131, 132, 132, 132, 133, 133, 133, 132, 129, 126, 121, 119, 119, 122, 125, 130, 133, 134, 134, 133, 
132, 131, 130, 128, 126, 124, 122, 121, 123, 125, 128, 131, 133, 135, 134, 133, 131, 128, 125, 124, 
123, 123, 125, 126, 128, 129, 130, 132, 133, 133, 132, 130, 127, 124, 122, 122, 123, 126, 128, 130, 
131, 131, 131, 131, 130, 129, 127, 126, 126, 125, 125, 126, 127, 128, 130, 132, 137, 143, 143, 135, 
121, 105, 94, 100, 117, 138, 155, 160, 151, 134, 116, 106, 106, 115, 128, 137, 139, 135, 128, 124, 
125, 130, 136, 138, 133, 125, 116, 111, 113, 123, 134, 144, 148, 143, 133, 121, 113, 111, 116, 124, 
133, 138, 139, 135, 130, 127, 125, 125, 126, 126, 125, 126, 125, 127, 130, 132, 135, 135, 132, 127, 
121, 118, 120, 124, 130, 135, 136, 135, 131, 126, 123, 122, 123, 126, 129, 130, 131, 129, 128, 128, 
129, 129, 129, 128, 127, 126, 125, 126, 126, 128, 130, 131, 132, 130, 128, 126, 125, 124, 125, 125, 
129, 131, 132, 134, 132, 129, 126, 123, 122, 123, 125, 129, 133, 135, 137, 134, 129, 123, 117, 117, 
120, 126, 134, 140, 141, 140, 131, 121, 114, 110, 115, 125, 136, 146, 148, 143, 131, 118, 108, 106, 
110, 125, 141, 153, 156, 146, 129, 111, 98, 98, 111, 130, 151, 162, 159, 145, 121, 99, 87, 93, 
115, 142, 166, 175, 162, 135, 101, 79, 78, 98, 133, 167, 185, 180, 151, 109, 75, 59, 79, 121, 
166, 201, 199, 165, 112, 64, 44, 62, 111, 172, 214, 217, 181, 113, 52, 22, 42, 106, 181, 237, 
242, 190, 107, 26, 1, 28, 110, 207, 255, 253, 190, 83, 6, 1, 22, 131, 237, 255, 255, 172, 
43, 1, 1, 35, 175, 255, 255, 247, 125, 1, 1, 1, 85, 236, 255, 255, 216, 41, 1, 1, 
15, 180, 255, 255, 255, 119, 1, 1, 1, 93, 255, 255, 255, 201, 16, 1, 1, 37, 223, 255, 
255, 235, 48, 1, 1, 9, 198, 255, 255, 253, 80, 1, 1, 1, 157, 255, 255, 255, 113, 1, 
1, 2, 134, 254, 255, 245, 128, 15, 1, 21, 125, 216, 247, 205, 132, 74, 59, 84, 120, 145, 
148, 143, 142, 150, 154, 137, 102, 66, 62, 103, 171, 225, 223, 158, 63, 6, 19, 105, 213, 255, 
235, 132, 26, 1, 38, 145, 236, 250, 190, 91, 29, 37, 103, 174, 202, 175, 123, 88, 94, 126, 
150, 143, 114, 94, 108, 149, 183, 178, 127, 69, 49, 88, 162, 215, 206, 138, 63, 37, 78, 153, 
203, 195, 137, 80, 68, 104, 154, 172, 147, 108, 92, 117, 155, 169, 141, 95, 73, 101, 156, 192, 
176, 118, 68, 68, 118, 174, 188, 152, 99, 78, 104, 148, 169, 146, 106, 89, 115, 156, 172, 144, 
96, 76, 103, 156, 183, 161, 110, 76, 89, 140, 205, 250, 249, 195, 108, 23, 1, 1, 36, 120, 
198, 240, 239, 203, 154, 117, 101, 104, 115, 117, 104, 81, 61, 62, 92, 144, 201, 240, 245, 211, 
150, 82, 31, 13, 30, 73, 123, 164, 188, 193, 185, 172, 158, 144, 127, 106, 81, 59, 51, 62, 
95, 143, 191, 225, 231, 206, 160, 105, 58, 33, 36, 61, 101, 142, 175, 196, 200, 190, 170, 143, 
113, 84, 62, 52, 60, 85, 124, 168, 203, 220, 212, 180, 133, 84, 47, 33, 45, 80, 126, 169, 
200, 212, 202, 176, 139, 100, 69, 53, 53, 71, 104, 143, 181, 206, 212, 194, 158, 112, 71, 43, 
39, 61, 101, 150, 193, 216, 214, 188, 146, 101, 63, 44, 48, 74, 114, 158, 192, 209, 204, 178, 
139, 97, 62, 45, 52, 80, 123, 167, 200, 213, 201, 167, 122, 77, 48, 43, 63, 103, 150, 189, 
211, 208, 180, 137, 91, 57, 44, 58, 92, 137, 178, 205, 208, 186, 147, 102, 65, 48, 55, 86, 
130, 171, 201, 208, 188, 150, 104, 66, 48, 57, 88, 132, 173, 201, 205, 183, 144, 99, 64, 51, 
64, 97, 141, 179, 200, 198, 171, 131, 90, 61, 57, 76, 112, 154, 186, 198, 186, 155, 115, 79, 
61, 66, 93, 131, 168, 190, 190, 169, 133, 96, 72, 66, 84, 117, 153, 180, 187, 173, 143, 108, 
81, 72, 83, 111, 143, 170, 181, 172, 146, 115, 89, 79, 88, 110, 139, 161, 171, 165, 144, 118, 
97, 88, 95, 115, 138, 157, 162, 155, 138, 118, 105, 99, 105, 120, 136, 148, 152, 145, 132, 119, 
110, 113, 118, 127, 136, 138, 137, 133, 126, 123, 123, 125, 130, 132, 130, 127, 120, 120, 124, 132, 
141, 143, 139, 129, 115, 106, 106, 114, 133, 150, 159, 159, 139, 113, 91, 83, 96, 125, 159, 181, 
180, 156, 118, 80, 62, 70, 107, 156, 195, 207, 184, 131, 75, 36, 41, 85, 151, 211, 236, 212, 
149, 70, 12, 5, 49, 142, 234, 255, 250, 169, 51, 1, 1, 29, 161, 255, 255, 255, 150, 16, 
1, 1, 40, 215, 255, 255, 250, 91, 1, 1, 1, 101, 255, 255, 255, 209, 20, 1, 1, 13, 
204, 255, 255, 255, 99, 1, 1, 1, 89, 255, 255, 255, 209, 8, 1, 1, 17, 219, 255, 255, 
255, 64, 1, 1, 1, 152, 255, 255, 255, 148, 1, 1, 1, 71, 255, 255, 255, 201, 10, 1, 
1, 44, 228, 255, 255, 222, 39, 1, 1, 33, 209, 255, 255, 219, 58, 1, 1, 53, 194, 255, 
255, 175, 60, 2, 24, 112, 202, 235, 195, 111, 44, 40, 98, 178, 223, 200, 124, 47, 23, 71, 
162, 237, 241, 171, 66, 2, 12, 100, 214, 255, 242, 141, 24, 1, 18, 130, 240, 255, 231, 109, 
10, 1, 39, 163, 250, 255, 196, 78, 4, 7, 85, 191, 250, 229, 143, 53, 20, 58, 140, 209, 
216, 164, 89, 46, 62, 125, 188, 205, 167, 99, 52, 61, 117, 183, 210, 180, 111, 52, 46, 96, 
170, 215, 201, 137, 66, 38, 71, 141, 203, 212, 164, 94, 48, 59, 115, 177, 204, 176, 118, 69, 
64, 103, 157, 188, 174, 129, 86, 76, 104, 147, 175, 166, 130, 93, 84, 109, 147, 171, 162, 128, 
94, 85, 108, 145, 169, 163, 132, 99, 87, 105, 138, 163, 161, 136, 107, 94, 106, 132, 153, 154, 
136, 114, 104, 112, 132, 145, 145, 132, 116, 112, 119, 133, 141, 139, 128, 117, 117, 123, 133, 140, 
135, 128, 120, 119, 124, 130, 134, 133, 130, 126, 125, 126, 126, 128, 129, 131, 132, 130, 126, 122, 
121, 126, 134, 138, 135, 127, 118, 117, 125, 136, 141, 135, 123, 113, 115, 129, 142, 146, 134, 117, 
107, 114, 132, 147, 147, 131, 112, 106, 117, 140, 152, 144, 122, 103, 104, 125, 149, 157, 141, 114, 
97, 107, 134, 157, 156, 131, 102, 94, 115, 147, 165, 152, 119, 93, 95, 125, 157, 165, 142, 106, 
90, 106, 141, 166, 157, 124, 92, 90, 122, 159, 171, 147, 106, 83, 98, 138, 170, 166, 129, 92, 
85, 115, 157, 173, 151, 107, 82, 96, 138, 172, 168, 129, 88, 82, 116, 159, 177, 151, 105, 79, 
96, 141, 174, 167, 125, 85, 82, 120, 165, 177, 147, 99, 77, 100, 147, 177, 163, 119, 82, 87, 
128, 169, 173, 136, 91, 79, 110, 158, 178, 154, 106, 76, 87, 134, 185, 207, 190, 147, 105, 80, 
74, 77, 85, 101, 125, 155, 182, 199, 202, 187, 159, 123, 88, 63, 53, 59, 78, 106, 133, 158, 
176, 185, 186, 178, 164, 143, 120, 95, 73, 62, 60, 73, 98, 130, 164, 191, 204, 201, 183, 154, 
122, 92, 71, 62, 64, 77, 97, 121, 146, 168, 186, 194, 192, 177, 151, 120, 87, 62, 50, 55, 
75, 107, 141, 171, 192, 199, 193, 176, 151, 124, 99, 78, 64, 61, 69, 89, 117, 148, 178, 198, 
204, 195, 171, 137, 103, 74, 57, 55, 66, 88, 117, 146, 171, 188, 195, 191, 176, 151, 121, 91, 
67, 54, 56, 72, 101, 136, 169, 192, 202, 197, 179, 152, 121, 92, 71, 60, 61, 74, 97, 126, 
156, 182, 197, 200, 188, 164, 132, 99, 71, 56, 55, 69, 94, 125, 157, 182, 196, 197, 185, 162, 
135, 105, 79, 62, 58, 67, 88, 118, 150, 179, 197, 201, 190, 166, 134, 103, 77, 61, 59, 70, 
92, 120, 150, 175, 192, 196, 187, 166, 137, 106, 80, 63, 59, 69, 91, 120, 151, 176, 192, 196, 
185, 164, 135, 104, 79, 64, 62, 72, 94, 122, 151, 176, 190, 193, 182, 161, 133, 104, 79, 65, 
63, 75, 97, 125, 153, 177, 190, 190, 178, 156, 129, 102, 79, 67, 67, 79, 102, 129, 156, 178, 
189, 187, 173, 151, 123, 98, 78, 69, 72, 86, 108, 135, 161, 178, 186, 182, 167, 144, 117, 93, 
77, 71, 77, 93, 116, 141, 164, 179, 183, 177, 160, 136, 111, 89, 76, 74, 83, 101, 124, 148, 
167, 178, 178, 168, 150, 127, 106, 88, 79, 80, 91, 110, 132, 153, 169, 176, 173, 161, 142, 119, 
99, 86, 81, 86, 100, 120, 141, 159, 169, 171, 164, 150, 131, 112, 96, 87, 88, 96, 111, 129, 
147, 161, 168, 165, 156, 140, 121, 106, 94, 90, 95, 106, 122, 139, 153, 161, 162, 156, 144, 129, 
114, 103, 99, 104, 117, 131, 143, 148, 145, 136, 127, 120, 118, 121, 127, 133, 137, 137, 132, 126, 
121, 120, 125, 132, 137, 138, 134, 128, 121, 118, 119, 124, 130, 135, 135, 131, 126, 122, 122, 126, 
131, 136, 138, 135, 128, 121, 115, 114, 119, 127, 135, 141, 142, 140, 134, 126, 120, 117, 116, 118, 
122, 125, 130, 135, 139, 142, 141, 137, 130, 121, 112, 107, 107, 114, 125, 138, 149, 154, 152, 144, 
130, 116, 104, 99, 101, 111, 125, 140, 151, 157, 156, 149, 135, 120, 105, 96, 95, 102, 116, 135, 
152, 163, 166, 158, 142, 121, 102, 90, 87, 94, 112, 134, 154, 168, 171, 163, 146, 124, 102, 87, 
82, 89, 106, 130, 153, 170, 177, 170, 154, 129, 103, 83, 75, 81, 100, 126, 154, 176, 184, 179, 
159, 130, 100, 77, 68, 75, 96, 126, 157, 181, 191, 184, 162, 131, 98, 73, 62, 69, 92, 126, 
160, 186, 198, 189, 164, 130, 93, 66, 55, 64, 91, 129, 166, 194, 203, 191, 164, 125, 87, 60, 
51, 63, 94, 133, 172, 199, 206, 193, 161, 119, 79, 53, 47, 63, 97, 140, 180, 206, 211, 193, 
156, 110, 70, 45, 43, 64, 103, 150, 191, 215, 214, 189, 146, 99, 58, 37, 41, 70, 116, 165, 
204, 222, 213, 179, 132, 82, 45, 32, 45, 82, 134, 183, 217, 226, 206, 165, 113, 64, 33, 30, 
54, 101, 155, 201, 227, 224, 194, 144, 89, 45, 25, 35, 72, 126, 180, 220, 233, 215, 172, 116, 
62, 29, 24, 50, 99, 155, 206, 233, 229, 195, 141, 83, 39, 21, 34, 76, 131, 188, 227, 236, 
213, 164, 104, 52, 23, 24, 58, 110, 170, 217, 237, 224, 182, 123, 67, 29, 20, 45, 94, 154, 
207, 235, 230, 195, 138, 80, 36, 20, 37, 82, 141, 196, 231, 233, 203, 150, 90, 44, 22, 33, 
74, 131, 188, 226, 232, 207, 157, 98, 50, 25, 33, 70, 126, 182, 221, 230, 207, 160, 102, 55, 
29, 35, 71, 124, 179, 217, 226, 204, 158, 103, 57, 33, 40, 75, 126, 178, 214, 221, 198, 154, 
101, 58, 38, 47, 82, 131, 179, 210, 214, 189, 146, 96, 59, 44, 56, 92, 138, 181, 206, 205, 
178, 135, 91, 60, 52, 69, 105, 147, 183, 200, 193, 163, 124, 86, 63, 63, 84, 119, 156, 182, 
191, 178, 148, 113, 83, 69, 78, 100, 132, 161, 178, 178, 161, 133, 117, 121, 136, 146, 138, 114, 
87, 72, 81, 112, 150, 174, 168, 133, 83, 41, 31, 62, 126, 201, 250, 255, 226, 155, 81, 38, 
53, 117, 191, 233, 222, 158, 72, 7, 1, 8, 68, 142, 189, 192, 158, 106, 70, 71, 110, 173, 
230, 254, 239, 189, 129, 84, 70, 87, 120, 148, 153, 130, 89, 49, 28, 38, 73, 123, 165, 185, 
180, 159, 136, 127, 136, 161, 188, 203, 196, 168, 128, 93, 71, 69, 82, 100, 113, 112, 101, 87, 
79, 85, 106, 137, 168, 187, 191, 181, 165, 150, 143, 145, 150, 152, 146, 130, 107, 85, 69, 66, 
74, 90, 107, 119, 125, 126, 127, 132, 143, 159, 174, 184, 184, 174, 158, 140, 126, 116, 111, 109, 
106, 100, 92, 85, 82, 85, 96, 112, 130, 145, 154, 159, 161, 161, 161, 162, 162, 159, 153, 141, 
126, 111, 99, 91, 88, 90, 94, 99, 104, 109, 116, 124, 134, 146, 157, 165, 169, 167, 162, 154, 
145, 136, 128, 121, 113, 106, 99, 94, 91, 93, 98, 107, 117, 128, 137, 145, 151, 155, 158, 159, 
158, 156, 150, 142, 132, 121, 112, 105, 100, 98, 99, 101, 105, 110, 117, 124, 132, 140, 148, 154, 
157, 157, 155, 150, 143, 136, 129, 122, 116, 110, 106, 103, 102, 104, 108, 114, 121, 128, 135, 141, 
146, 149, 151, 150, 148, 144, 139, 133, 126, 120, 115, 111, 108, 108, 109, 112, 116, 120, 125, 131, 
136, 140, 144, 146, 146, 144, 141, 137, 132, 127, 123, 119, 117, 115, 114, 115, 116, 119, 122, 126, 
130, 133, 137, 139, 140, 139, 138, 136, 133, 130, 127, 125, 123, 121, 120, 120, 121, 122, 123, 125, 
127, 129, 131, 132, 133, 133, 133, 132, 130, 129, 128, 127, 126, 126, 127, 127, 127, 128, 128, 128, 
128, 128, 128, 128, 127, 127, 126, 126, 126, 126, 126, 127, 129, 131, 132, 134, 134, 134, 133, 131, 
130, 127, 125, 123, 121, 118, 115, 112, 112, 116, 122, 131, 140, 147, 151, 152, 150, 146, 141, 135, 
128, 121, 112, 105, 99, 95, 96, 102, 112, 123, 136, 147, 157, 163, 165, 164, 158, 147, 133, 119, 
107, 97, 91, 90, 93, 99, 109, 121, 133, 146, 158, 167, 171, 169, 162, 151, 135, 119, 104, 93, 
86, 84, 87, 95, 107, 121, 136, 151, 164, 173, 176, 173, 164, 150, 133, 115, 99, 86, 80, 79, 
84, 94, 109, 127, 144, 160, 173, 179, 179, 173, 160, 143, 124, 105, 89, 79, 74, 76, 86, 100, 
119, 139, 158, 173, 181, 183, 178, 166, 149, 129, 109, 91, 78, 71, 72, 80, 96, 116, 137, 158, 
175, 184, 186, 180, 167, 149, 128, 107, 89, 75, 69, 71, 80, 97, 118, 142, 163, 179, 187, 187, 
179, 164, 144, 122, 101, 83, 72, 68, 73, 85, 105, 127, 151, 171, 185, 189, 185, 172, 153, 131, 
109, 89, 76, 69, 71, 81, 98, 120, 143, 165, 180, 188, 186, 175, 157, 135, 112, 93, 78, 71, 
73, 82, 98, 119, 141, 162, 177, 185, 183, 173, 156, 134, 112, 93, 79, 74, 77, 87, 104, 124, 
145, 163, 176, 180, 177, 165, 148, 128, 108, 91, 81, 79, 84, 97, 114, 133, 152, 166, 173, 173, 
166, 152, 135, 117, 101, 90, 86, 88, 97, 111, 127, 144, 158, 165, 167, 162, 151, 137, 121, 107, 
98, 94, 96, 103, 114, 127, 140, 150, 156, 158, 154, 146, 135, 123, 112, 105, 102, 104, 111, 120, 
130, 139, 145, 147, 147, 143, 137, 130, 123, 117, 114, 113, 115, 120, 126, 132, 136, 138, 137, 135, 
132, 128, 125, 124, 124, 126, 127, 129, 129, 129, 128, 127, 125, 124, 124, 125, 127, 129, 132, 135, 
137, 138, 136, 132, 126, 119, 113, 110, 111, 117, 125, 135, 143, 149, 151, 148, 140, 130, 119, 109, 
102, 101, 104, 113, 126, 140, 152, 161, 163, 158, 146, 128, 110, 94, 85, 86, 96, 113, 135, 156, 
171, 177, 172, 157, 137, 113, 93, 79, 75, 83, 101, 125, 151, 173, 185, 186, 173, 149, 120, 92, 
72, 63, 69, 89, 119, 151, 179, 195, 196, 181, 154, 120, 88, 65, 56, 63, 86, 119, 154, 184, 
201, 202, 185, 154, 116, 82, 57, 49, 59, 86, 125, 164, 195, 210, 205, 181, 145, 104, 68, 47, 
46, 65, 100, 141, 180, 206, 213, 199, 166, 124, 82, 53, 42, 53, 83, 124, 167, 197, 205, 194, 
170, 144, 127, 118, 118, 122, 125, 125, 125, 126, 131, 139, 145, 144, 132, 110, 83, 62, 54, 64, 
92, 129, 167, 192, 199, 187, 162, 133, 112, 102, 105, 118, 136, 152, 162, 163, 152, 135, 119, 111, 
112, 121, 133, 140, 139, 131, 119, 109, 105, 109, 119, 130, 138, 140, 135, 128, 121, 119, 122, 129, 
137, 141, 141, 135, 127, 121, 118, 120, 125, 132, 136, 136, 134, 129, 125, 123, 125, 129, 133, 135, 
134, 130, 125, 121, 118, 118, 121, 124, 126, 126, 125, 123, 122, 123, 127, 132, 137, 141, 143, 142, 
140, 137, 134, 133, 132, 131, 129, 126, 121, 116, 112, 109, 109, 111, 115, 119, 122, 125, 128, 131, 
135, 140, 145, 149, 152, 152, 149, 144, 138, 132, 126, 121, 117, 113, 109, 105, 102, 101, 103, 107, 
113, 121, 129, 136, 143, 148, 153, 156, 157, 157, 156, 151, 144, 136, 127, 118, 109, 102, 98, 95, 
95, 96, 100, 105, 113, 122, 132, 142, 152, 159, 164, 166, 166, 162, 156, 148, 139, 129, 118, 108, 
98, 91, 87, 85, 88, 94, 103, 113, 125, 137, 148, 157, 165, 171, 173, 171, 166, 158, 147, 134, 
121, 108, 97, 88, 83, 81, 82, 88, 97, 108, 122, 136, 150, 161, 170, 176, 177, 175, 168, 158, 
147, 133, 118, 104, 92, 83, 77, 77, 80, 89, 100, 115, 129, 145, 158, 169, 176, 179, 177, 172, 
163, 151, 136, 121, 105, 92, 82, 77, 76, 80, 89, 101, 116, 131, 146, 160, 171, 177, 179, 176, 
168, 158, 144, 129, 114, 100, 88, 81, 78, 80, 87, 98, 112, 127, 142, 155, 166, 172, 175, 173, 
167, 157, 144, 130, 115, 102, 91, 85, 83, 85, 93, 103, 116, 130, 144, 155, 163, 168, 169, 165, 
158, 147, 135, 122, 110, 100, 94, 91, 92, 97, 106, 116, 128, 138, 148, 155, 159, 160, 157, 151, 
142, 133, 123, 114, 107, 103, 102, 104, 113, 124, 135, 142, 143, 139, 132, 126, 124, 125, 128, 131, 
133, 132, 131, 130, 130, 132, 135, 136, 134, 129, 121, 112, 106, 104, 106, 114, 124, 135, 144, 150, 
154, 156, 155, 151, 143, 133, 120, 106, 94, 85, 84, 91, 107, 129, 151, 167, 174, 171, 161, 148, 
136, 124, 114, 105, 96, 89, 86, 89, 100, 119, 142, 164, 181, 187, 181, 166, 144, 121, 100, 86, 
78, 78, 83, 94, 110, 129, 150, 170, 184, 189, 184, 167, 143, 115, 90, 71, 63, 67, 81, 103, 
128, 152, 172, 185, 189, 183, 169, 147, 123, 98, 77, 64, 63, 74, 95, 123, 152, 176, 191, 193, 
184, 164, 139, 113, 90, 75, 69, 73, 86, 107, 131, 156, 176, 187, 186, 174, 153, 128, 103, 83, 
73, 74, 85, 105, 128, 149, 166, 175, 175, 165, 149, 130, 111, 97, 88, 88, 95, 109, 126, 143, 
155, 162, 162, 155, 142, 127, 113, 104, 100, 103, 112, 123, 133, 141, 145, 144, 140, 135, 128, 123, 
120, 120, 122, 126, 129, 132, 132, 130, 126, 123, 119, 120, 123, 129, 137, 143, 146, 145, 138, 128, 
116, 105, 99, 101, 109, 123, 140, 156, 166, 167, 159, 141, 120, 98, 82, 77, 85, 104, 131, 158, 
179, 188, 182, 163, 133, 100, 73, 59, 62, 83, 116, 153, 185, 204, 203, 182, 146, 104, 68, 46, 
46, 68, 106, 151, 191, 215, 215, 192, 150, 103, 61, 38, 39, 64, 107, 157, 199, 221, 217, 188, 
143, 94, 54, 35, 43, 74, 122, 170, 206, 219, 206, 170, 122, 77, 47, 42, 63, 102, 149, 186, 
207, 202, 176, 136, 95, 65, 58, 71, 101, 138, 169, 186, 184, 164, 134, 105, 85, 81, 93, 115, 
140, 157, 163, 156, 138, 119, 106, 103, 112, 128, 142, 149, 144, 131, 114, 103, 101, 114, 135, 158, 
171, 167, 145, 113, 82, 66, 74, 102, 146, 187, 210, 203, 165, 110, 56, 25, 32, 77, 143, 210, 
249, 243, 195, 116, 38, 1, 1, 48, 138, 227, 255, 255, 218, 120, 21, 1, 1, 30, 141, 241, 
255, 255, 226, 104, 8, 1, 1, 36, 165, 255, 255, 255, 205, 68, 1, 1, 1, 76, 215, 255, 
255, 251, 147, 22, 1, 1, 23, 148, 250, 255, 255, 196, 66, 1, 1, 12, 112, 226, 255, 255, 
202, 93, 11, 1, 23, 116, 206, 252, 236, 166, 83, 28, 30, 82, 156, 212, 218, 172, 101, 44, 
40, 90, 158, 203, 196, 137, 61, 6, 11, 73, 163, 237, 253, 208, 124, 44, 15, 55, 141, 236, 
255, 246, 163, 37, 1, 1, 15, 132, 243, 255, 255, 177, 45, 1, 1, 55, 196, 255, 255, 253, 
136, 7, 1, 1, 25, 178, 255, 255, 255, 138, 9, 1, 1, 85, 228, 255, 255, 220, 67, 1, 
1, 1, 56, 199, 255, 255, 247, 152, 51, 8, 36, 120, 214, 255, 247, 171, 62, 1, 1, 1, 
73, 174, 246, 255, 228, 161, 96, 68, 86, 136, 191, 216, 196, 136, 58, 5, 1, 18, 90, 167, 
223, 240, 215, 168, 123, 99, 106, 132, 160, 170, 150, 110, 61, 27, 26, 60, 117, 176, 215, 224, 
203, 164, 127, 104, 102, 114, 129, 134, 123, 101, 78, 66, 76, 104, 146, 183, 204, 201, 177, 142, 
110, 91, 89, 100, 114, 125, 126, 120, 112, 108, 115, 132, 151, 168, 172, 162, 141, 116, 97, 91, 
98, 114, 131, 143, 146, 139, 128, 119, 116, 121, 129, 137, 141, 139, 133, 125, 120, 122, 128, 135, 
139, 137, 129, 117, 106, 101, 105, 117, 133, 149, 160, 163, 158, 146, 131, 117, 107, 100, 98, 99, 
103, 112, 124, 139, 155, 168, 175, 173, 160, 138, 111, 88, 71, 67, 77, 97, 125, 152, 174, 187, 
188, 177, 159, 134, 108, 85, 69, 64, 72, 90, 118, 150, 178, 196, 200, 188, 162, 129, 95, 68, 
55, 58, 76, 105, 138, 169, 190, 198, 190, 170, 140, 109, 83, 66, 63, 74, 97, 127, 156, 178, 
190, 187, 170, 144, 114, 89, 74, 73, 84, 106, 131, 154, 170, 174, 167, 152, 132, 113, 99, 93, 
97, 108, 123, 137, 148, 151, 148, 141, 130, 121, 116, 115, 120, 127, 133, 137, 136, 130, 122, 115, 
112, 116, 125, 137, 149, 155, 154, 144, 127, 109, 94, 87, 92, 109, 133, 158, 177, 182, 173, 150, 
118, 86, 64, 60, 75, 108, 147, 184, 207, 207, 184, 142, 92, 50, 29, 38, 78, 135, 196, 237, 
244, 212, 150, 78, 22, 1, 24, 83, 157, 222, 253, 240, 187, 114, 49, 15, 24, 69, 134, 191, 
222, 215, 175, 120, 73, 53, 66, 105, 150, 182, 186, 162, 121, 83, 66, 81, 121, 169, 203, 204, 
169, 110, 52, 21, 35, 89, 168, 237, 255, 237, 158, 60, 1, 1, 16, 114, 228, 255, 255, 235, 
119, 10, 1, 1, 29, 171, 255, 255, 255, 205, 42, 1, 1, 1, 93, 238, 255, 255, 252, 113, 
1, 1, 1, 32, 205, 255, 255, 255, 170, 15, 1, 1, 12, 159, 255, 255, 255, 198, 34, 1, 
1, 10, 139, 254, 255, 255, 187, 46, 1, 1, 29, 150, 243, 255, 237, 142, 50, 8, 30, 103, 
180, 218, 202, 139, 80, 54, 79, 138, 191, 205, 168, 97, 38, 29, 78, 170, 244, 255, 206, 92, 
4, 1, 18, 140, 251, 255, 255, 158, 16, 1, 1, 46, 220, 255, 255, 239, 79, 1, 1, 1, 
115, 255, 255, 255, 200, 27, 1, 1, 24, 183, 255, 255, 255, 138, 10, 1, 1, 59, 194, 255, 
255, 237, 131, 22, 1, 1, 56, 176, 255, 255, 243, 139, 22, 1, 1, 66, 202, 255, 255, 225, 
87, 1, 1, 18, 138, 246, 255, 243, 139, 21, 1, 16, 111, 215, 255, 224, 142, 63, 35, 65, 
124, 172, 181, 154, 118, 101, 113, 137, 150, 140, 112, 91, 95, 126, 164, 183, 167, 124, 83, 66, 
86, 130, 171, 187, 171, 135, 98, 78, 83, 106, 140, 168, 178, 166, 132, 94, 72, 78, 115, 161, 
190, 181, 138, 90, 67, 84, 130, 171, 179, 150, 108, 87, 100, 136, 161, 156, 124, 93, 92, 123, 
164, 178, 153, 105, 71, 79, 122, 172, 189, 161, 113, 77, 80, 116, 155, 170, 153, 124, 103, 105, 
123, 138, 141, 133, 124, 122, 127, 133, 134, 130, 126, 123, 123, 123, 127, 133, 141, 142, 131, 114, 
103, 111, 134, 156, 158, 135, 105, 93, 110, 142, 161, 150, 120, 98, 105, 134, 158, 153, 123, 96, 
99, 129, 160, 163, 133, 100, 92, 116, 149, 161, 143, 114, 101, 114, 138, 150, 139, 119, 109, 118, 
136, 145, 139, 124, 116, 118, 127, 134, 135, 132, 128, 124, 122, 124, 128, 134, 136, 129, 120, 118, 
127, 140, 141, 128, 111, 110, 127, 148, 149, 129, 107, 105, 127, 150, 150, 126, 105, 109, 134, 153, 
144, 118, 101, 112, 144, 174, 182, 162, 130, 102, 85, 77, 78, 92, 123, 166, 200, 206, 176, 127, 
86, 72, 83, 102, 117, 125, 135, 151, 164, 163, 147, 128, 118, 120, 122, 113, 95, 85, 98, 131, 
166, 183, 176, 156, 136, 118, 98, 78, 69, 83, 121, 163, 187, 182, 160, 137, 123, 111, 97, 84, 
85, 106, 137, 159, 163, 156, 149, 147, 148, 149, 141, 124, 100, 78, 69, 81, 110, 150, 185, 201, 
194, 163, 120, 79, 57, 60, 86, 125, 161, 182, 183, 165, 138, 112, 96, 94, 103, 118, 132, 140, 
141, 138, 133, 131, 130, 130, 130, 127, 123, 120, 118, 121, 126, 133, 137, 138, 134, 127, 121, 119, 
122, 129, 136, 140, 137, 129, 118, 110, 108, 114, 128, 144, 157, 159, 150, 131, 109, 92, 87, 95, 
116, 141, 164, 175, 172, 154, 127, 100, 80, 75, 86, 110, 141, 168, 184, 184, 166, 136, 102, 75, 
63, 70, 96, 133, 170, 196, 201, 184, 147, 103, 65, 45, 52, 83, 130, 178, 212, 219, 197, 151, 
97, 50, 29, 39, 79, 136, 192, 228, 232, 201, 146, 84, 36, 17, 34, 83, 147, 206, 239, 237, 
198, 135, 70, 23, 11, 37, 94, 163, 221, 249, 236, 187, 118, 51, 9, 7, 46, 113, 186, 240, 
254, 228, 166, 91, 28, 1, 14, 68, 143, 214, 252, 250, 206, 133, 59, 8, 2, 35, 103, 180, 
238, 255, 233, 170, 93, 28, 1, 14, 70, 147, 216, 253, 247, 198, 123, 51, 7, 6, 49, 121, 
194, 243, 250, 212, 145, 72, 21, 9, 41, 104, 175, 228, 243, 217, 158, 89, 36, 18, 40, 94, 
160, 212, 232, 213, 163, 101, 51, 30, 46, 92, 151, 199, 219, 204, 161, 107, 63, 44, 58, 98, 
148, 188, 204, 190, 153, 108, 73, 61, 75, 110, 149, 178, 186, 171, 139, 105, 82, 79, 95, 124, 
152, 169, 168, 150, 124, 102, 92, 99, 117, 139, 155, 157, 146, 127, 108, 99, 106, 127, 151, 166, 
162, 137, 103, 76, 72, 96, 142, 188, 211, 196, 145, 79, 28, 18, 61, 141, 223, 255, 248, 177, 
71, 1, 1, 13, 116, 234, 255, 255, 227, 85, 1, 1, 1, 71, 227, 255, 255, 255, 119, 1, 
1, 1, 32, 211, 255, 255, 255, 164, 1, 1, 1, 7, 183, 255, 255, 255, 202, 16, 1, 1, 
1, 153, 255, 255, 255, 214, 24, 1, 1, 1, 141, 255, 255, 255, 218, 26, 1, 1, 1, 140, 
255, 255, 255, 217, 24, 1, 1, 1, 149, 255, 255, 255, 210, 17, 1, 1, 1, 166, 255, 255, 
255, 199, 8, 1, 1, 1, 188, 255, 255, 255, 177, 1, 1, 1, 18, 204, 255, 255, 255, 145, 
1, 1, 1, 36, 219, 255, 255, 255, 114, 1, 1, 1, 59, 230, 255, 255, 240, 87, 1, 1, 
1, 94, 238, 255, 255, 222, 69, 1, 1, 7, 120, 241, 255, 255, 193, 62, 1, 1, 23, 135, 
238, 255, 250, 172, 67, 3, 1, 45, 138, 221, 255, 235, 164, 80, 21, 12, 55, 129, 200, 237, 
224, 169, 96, 39, 22, 53, 117, 187, 230, 227, 179, 106, 42, 17, 43, 110, 187, 239, 239, 185, 
102, 29, 2, 36, 116, 205, 254, 246, 177, 79, 8, 1, 43, 143, 237, 255, 240, 148, 40, 1, 
1, 73, 188, 255, 255, 215, 98, 8, 1, 19, 127, 236, 255, 250, 158, 36, 1, 1, 70, 196, 
255, 255, 209, 84, 1, 1, 27, 148, 246, 255, 239, 130, 19, 1, 10, 107, 226, 255, 251, 165, 
45, 1, 1, 78, 197, 255, 255, 189, 71, 1, 1, 58, 174, 252, 255, 204, 90, 7, 1, 46, 
158, 246, 255, 215, 104, 13, 1, 35, 146, 241, 255, 225, 116, 17, 1, 26, 135, 237, 255, 234, 
126, 21, 1, 20, 125, 233, 255, 238, 136, 25, 1, 15, 114, 227, 255, 243, 146, 32, 1, 12, 
106, 220, 255, 245, 153, 40, 1, 10, 100, 213, 255, 246, 158, 46, 1, 11, 98, 207, 255, 243, 
156, 50, 1, 15, 102, 205, 255, 238, 150, 50, 1, 22, 109, 207, 254, 230, 142, 48, 2, 32, 
118, 210, 251, 218, 132, 44, 7, 43, 129, 214, 246, 207, 121, 40, 12, 54, 140, 218, 241, 196, 
111, 37, 19, 66, 150, 219, 233, 183, 101, 37, 28, 80, 159, 219, 222, 169, 92, 38, 40, 95, 
169, 216, 208, 152, 82, 42, 55, 118, 197, 249, 247, 186, 96, 21, 2, 41, 118, 188, 214, 184, 
119, 60, 43, 78, 147, 212, 237, 211, 149, 85, 52, 62, 101, 142, 159, 144, 111, 83, 80, 107, 
148, 180, 186, 166, 135, 114, 114, 131, 147, 146, 124, 90, 65, 68, 98, 142, 174, 178, 154, 119, 
99, 108, 142, 180, 195, 174, 124, 70, 42, 54, 99, 154, 197, 210, 189, 147, 104, 80, 83, 108, 
141, 165, 165, 143, 109, 79, 67, 81, 113, 152, 180, 188, 174, 146, 118, 101, 101, 115, 133, 144, 
142, 127, 106, 89, 86, 98, 123, 151, 171, 176, 166, 147, 127, 113, 110, 116, 124, 129, 126, 116, 
105, 97, 99, 112, 132, 152, 166, 170, 162, 147, 131, 119, 113, 114, 116, 117, 115, 110, 105, 104, 
110, 123, 139, 155, 165, 167, 159, 146, 132, 119, 111, 108, 108, 108, 108, 108, 109, 113, 122, 134, 
148, 159, 165, 164, 155, 142, 128, 115, 107, 102, 101, 102, 105, 109, 115, 123, 133, 145, 155, 162, 
164, 159, 149, 135, 121, 109, 100, 96, 96, 100, 106, 114, 123, 134, 145, 155, 162, 165, 162, 153, 
140, 125, 111, 99, 93, 91, 95, 102, 112, 124, 136, 147, 156, 163, 164, 162, 154, 142, 127, 113, 
100, 91, 88, 91, 99, 110, 124, 138, 150, 160, 165, 166, 162, 154, 141, 127, 111, 98, 89, 86, 
88, 97, 109, 124, 139, 153, 163, 169, 169, 164, 154, 140, 124, 108, 95, 87, 84, 87, 97, 111, 
127, 143, 157, 167, 172, 170, 163, 151, 136, 119, 103, 91, 84, 82, 88, 99, 114, 131, 148, 163, 
172, 175, 171, 162, 147, 130, 112, 97, 86, 80, 82, 90, 103, 120, 139, 155, 168, 176, 176, 170, 
157, 141, 122, 104, 90, 81, 78, 83, 94, 110, 129, 148, 164, 175, 179, 175, 165, 149, 130, 111, 
95, 83, 78, 79, 88, 103, 121, 141, 159, 172, 180, 179, 171, 156, 137, 117, 98, 83, 73, 72, 
81, 99, 123, 149, 170, 183, 187, 180, 165, 145, 124, 104, 89, 79, 77, 81, 92, 109, 129, 151, 
169, 180, 183, 176, 161, 140, 117, 97, 84, 78, 80, 90, 105, 122, 140, 156, 167, 173, 171, 163, 
149, 131, 113, 98, 88, 85, 90, 101, 116, 133, 148, 158, 163, 162, 156, 145, 133, 121, 110, 103, 
99, 99, 103, 112, 125, 140, 154, 163, 166, 159, 146, 130, 113, 101, 95, 96, 103, 113, 125, 135, 
144, 150, 153, 152, 148, 140, 130, 119, 109, 102, 100, 104, 113, 125, 137, 147, 152, 152, 148, 140, 
131, 122, 115, 111, 110, 111, 115, 121, 128, 135, 141, 145, 145, 143, 137, 129, 121, 115, 112, 113, 
116, 122, 129, 134, 137, 139, 138, 136, 133, 129, 126, 123, 121, 120, 121, 123, 126, 129, 132, 134, 
134, 132, 130, 128, 126, 125, 125, 126, 128, 129, 129, 129, 128, 127, 126, 126, 126, 126, 127, 128, 
130, 132, 133, 133, 133, 131, 127, 124, 120, 119, 119, 121, 125, 130, 135, 139, 141, 140, 136, 131, 
124, 118, 113, 112, 113, 118, 125, 133, 140, 146, 148, 146, 140, 131, 121, 112, 106, 104, 107, 115, 
126, 138, 148, 154, 155, 150, 141, 128, 115, 104, 98, 98, 104, 115, 129, 144, 156, 162, 161, 153, 
140, 124, 108, 96, 90, 93, 102, 118, 136, 153, 165, 169, 165, 152, 134, 114, 97, 86, 84, 91, 
106, 127, 148, 165, 175, 174, 164, 145, 123, 101, 84, 77, 81, 95, 117, 142, 164, 178, 182, 174, 
155, 130, 105, 84, 72, 73, 86, 108, 136, 162, 181, 188, 182, 163, 137, 108, 83, 68, 67, 79, 
102, 132, 161, 182, 192, 188, 169, 142, 110, 82, 65, 61, 73, 98, 130, 162, 186, 197, 192, 172, 
142, 108, 79, 61, 58, 72, 99, 133, 166, 190, 200, 193, 170, 138, 103, 74, 57, 57, 74, 104, 
140, 173, 195, 201, 190, 164, 129, 93, 67, 55, 60, 83, 116, 152, 182, 198, 198, 181, 151, 116, 
83, 62, 57, 69, 95, 130, 164, 189, 199, 191, 168, 135, 100, 72, 59, 62, 83, 114, 149, 178, 
194, 194, 176, 147, 113, 83, 65, 63, 78, 105, 138, 167, 186, 190, 178, 154, 123, 93, 74, 68, 
78, 101, 131, 159, 178, 184, 175, 154, 127, 100, 81, 75, 83, 103, 129, 154, 171, 176, 168, 149, 
126, 104, 90, 86, 94, 111, 131, 150, 161, 164, 162, 160, 160, 160, 157, 148, 130, 109, 89, 79, 
84, 102, 128, 152, 163, 157, 135, 104, 77, 63, 69, 92, 127, 162, 188, 198, 190, 171, 146, 123, 
108, 103, 106, 115, 126, 135, 141, 144, 140, 132, 119, 102, 87, 77, 76, 86, 108, 136, 164, 184, 
190, 180, 158, 131, 108, 95, 98, 114, 137, 160, 173, 172, 156, 131, 107, 95, 99, 115, 135, 149, 
151, 140, 122, 105, 97, 102, 117, 135, 149, 152, 144, 130, 117, 110, 113, 124, 137, 147, 148, 140, 
128, 116, 110, 113, 122, 133, 142, 144, 139, 130, 121, 116, 117, 124, 132, 138, 139, 134, 126, 118, 
114, 114, 120, 127, 133, 135, 133, 128, 124, 123, 125, 131, 138, 142, 144, 141, 135, 128, 124, 122, 
123, 125, 127, 126, 122, 118, 114, 112, 114, 118, 124, 130, 134, 136, 136, 136, 136, 138, 141, 143, 
144, 142, 138, 131, 125, 119, 116, 114, 114, 114, 114, 113, 113, 114, 116, 121, 127, 134, 140, 145, 
148, 148, 148, 147, 145, 142, 139, 135, 129, 123, 116, 110, 105, 103, 103, 105, 108, 113, 118, 123, 
129, 135, 141, 147, 152, 156, 157, 155, 151, 145, 138, 130, 123, 116, 110, 105, 101, 98, 98, 99, 
104, 111, 119, 128, 137, 145, 151, 156, 159, 160, 159, 156, 151, 143, 134, 125, 115, 106, 99, 95, 
93, 93, 96, 102, 109, 118, 128, 138, 147, 156, 162, 165, 166, 163, 158, 150, 141, 131, 120, 110, 
101, 94, 89, 88, 90, 95, 103, 113, 124, 136, 147, 156, 163, 168, 169, 167, 162, 155, 145, 133, 
121, 109, 99, 91, 86, 85, 87, 93, 101, 112, 124, 137, 149, 159, 166, 170, 171, 168, 162, 153, 
142, 130, 117, 105, 95, 88, 84, 84, 88, 96, 106, 118, 131, 144, 155, 164, 170, 172, 170, 165, 
156, 146, 133, 120, 107, 97, 89, 84, 84, 88, 95, 106, 118, 131, 144, 155, 163, 169, 171, 168, 
162, 152, 138, 124, 111, 100, 92, 89, 90, 94, 101, 110, 121, 132, 142, 152, 159, 162, 162, 158, 
151, 142, 131, 121, 112, 106, 102, 101, 103, 107, 112, 120, 127, 135, 141, 146, 148, 148, 146, 141, 
136, 130, 125, 121, 118, 117, 118, 119, 121, 124, 127, 129, 130, 131, 131, 130, 129, 128, 126, 125, 
125, 126, 128, 131, 133, 134, 135, 134, 132, 129, 127, 124, 122, 120, 119, 118, 119, 120, 123, 128, 
133, 138, 142, 145, 145, 142, 138, 131, 124, 118, 113, 109, 108, 109, 112, 117, 124, 132, 141, 148, 
153, 155, 153, 148, 139, 128, 117, 107, 100, 97, 98, 103, 111, 121, 133, 144, 154, 161, 163, 161, 
155, 144, 130, 115, 102, 93, 88, 89, 95, 106, 121, 136, 151, 162, 169, 171, 166, 156, 142, 126, 
109, 95, 85, 81, 84, 93, 108, 126, 144, 161, 172, 177, 175, 166, 151, 134, 115, 98, 85, 78, 
78, 86, 100, 119, 140, 159, 173, 180, 179, 170, 155, 136, 115, 97, 84, 77, 77, 86, 100, 120, 
141, 160, 174, 181, 179, 169, 152, 132, 111, 93, 81, 77, 80, 91, 108, 128, 148, 164, 175, 178, 
172, 159, 142, 122, 103, 89, 82, 82, 90, 104, 122, 140, 156, 167, 171, 168, 158, 143, 126, 110, 
97, 90, 90, 96, 108, 122, 138, 151, 159, 162, 158, 150, 137, 124, 112, 104, 100, 102, 108, 117, 
128, 137, 145, 149, 149, 145, 138, 130, 122, 116, 113, 113, 116, 121, 127, 132, 135, 136, 135, 133, 
130, 127, 125, 124, 125, 127, 130, 132, 132, 131, 129, 125, 121, 119, 118, 120, 124, 130, 136, 142, 
145, 145, 140, 132, 122, 112, 105, 102, 105, 113, 125, 139, 151, 159, 161, 155, 144, 128, 111, 96, 
88, 88, 97, 114, 135, 155, 170, 176, 172, 157, 136, 112, 91, 77, 74, 84, 103, 129, 155, 176, 
187, 185, 169, 144, 114, 87, 69, 63, 73, 96, 126, 158, 183, 196, 193, 174, 144, 110, 80, 61, 
58, 71, 99, 133, 167, 191, 200, 191, 167, 134, 100, 72, 58, 61, 81, 112, 146, 177, 195, 196, 
180, 151, 116, 85, 65, 61, 75, 103, 136, 166, 186, 190, 177, 152, 122, 95, 77, 74, 85, 106, 
133, 156, 171, 174, 165, 146, 123, 104, 92, 90, 99, 116, 134, 149, 157, 156, 147, 133, 119, 109, 
107, 111, 121, 132, 140, 143, 139, 131, 122, 115, 115, 121, 135, 151, 155, 141, 112, 80, 59, 61, 
87, 128, 166, 186, 178, 147, 104, 68, 55, 71, 112, 163, 205, 224, 215, 181, 136, 96, 72, 70, 
85, 109, 132, 145, 146, 138, 126, 114, 106, 103, 103, 107, 112, 122, 136, 153, 171, 184, 186, 175, 
150, 119, 91, 74, 75, 93, 122, 151, 168, 166, 144, 112, 79, 60, 61, 86, 130, 178, 207, 206, 
174, 127, 85, 63, 70, 99, 133, 156, 158, 137, 105, 78, 68, 81, 113, 150, 179, 189, 178, 155, 
131, 117, 119, 133, 152, 163, 160, 141, 113, 86, 70, 70, 84, 105, 125, 136, 137, 130, 122, 121, 
130, 147, 166, 180, 184, 175, 156, 134, 116, 105, 103, 106, 110, 109, 103, 94, 87, 87, 95, 112, 
133, 153, 167, 173, 171, 164, 157, 151, 149, 147, 143, 135, 122, 105, 90, 79, 75, 80, 91, 106, 
120, 132, 140, 146, 152, 158, 164, 169, 171, 168, 159, 144, 128, 111, 98, 90, 87, 88, 91, 96, 
103, 110, 120, 131, 144, 156, 166, 172, 172, 167, 158, 146, 134, 122, 112, 104, 97, 93, 91, 92, 
97, 105, 116, 130, 143, 154, 161, 164, 163, 159, 153, 144, 135, 126, 117, 109, 102, 97, 96, 98, 
104, 113, 123, 134, 142, 149, 153, 154, 152, 149, 144, 138, 130, 123, 116, 111, 107, 106, 108, 113, 
119, 125, 131, 136, 139, 141, 142, 141, 139, 136, 132, 128, 124, 121, 120, 120, 121, 123, 126, 128, 
129, 130, 130, 129, 129, 128, 128, 127, 127, 126, 127, 128, 130, 132, 135, 137, 138, 136, 132, 128, 
122, 118, 115, 113, 114, 116, 119, 124, 129, 135, 141, 147, 150, 151, 148, 142, 132, 122, 112, 104, 
99, 99, 102, 109, 118, 129, 140, 150, 158, 162, 162, 157, 148, 135, 121, 107, 95, 88, 87, 92, 
102, 116, 132, 148, 161, 169, 172, 169, 160, 146, 130, 112, 96, 85, 79, 81, 90, 105, 124, 144, 
162, 174, 179, 176, 166, 149, 129, 108, 90, 78, 75, 81, 95, 115, 137, 157, 171, 178, 175, 164, 
148, 129, 111, 97, 89, 88, 93, 104, 119, 135, 148, 157, 160, 157, 149, 137, 125, 114, 108, 107, 
111, 118, 126, 133, 137, 137, 135, 131, 126, 123, 122, 123, 127, 133, 138, 143, 144, 141, 133, 123, 
112, 103, 99, 100, 109, 123, 140, 156, 167, 169, 162, 146, 124, 103, 86, 78, 82, 96, 119, 143, 
165, 180, 182, 173, 154, 129, 102, 81, 69, 70, 85, 110, 140, 169, 189, 195, 185, 162, 129, 95, 
69, 57, 62, 83, 116, 151, 181, 198, 197, 180, 149, 114, 83, 63, 60, 73, 100, 133, 165, 187, 
194, 184, 161, 129, 98, 75, 67, 74, 96, 125, 154, 175, 183, 176, 156, 130, 104, 86, 81, 89, 
108, 131, 151, 163, 164, 154, 137, 120, 107, 102, 106, 117, 131, 141, 145, 142, 133, 123, 115, 113, 
118, 128, 140, 148, 149, 141, 127, 110, 98, 95, 104, 122, 146, 166, 175, 170, 149, 119, 89, 69, 
67, 86, 121, 161, 193, 206, 194, 158, 110, 65, 38, 40, 72, 124, 181, 223, 234, 209, 156, 90, 
36, 11, 25, 76, 146, 213, 251, 247, 202, 129, 55, 7, 2, 37, 109, 188, 246, 255, 230, 161, 
79, 16, 1, 21, 87, 167, 232, 255, 235, 172, 94, 30, 5, 28, 88, 161, 220, 240, 216, 158, 
91, 41, 29, 58, 114, 173, 210, 210, 175, 122, 73, 52, 66, 109, 159, 193, 195, 164, 114, 70, 
55, 76, 125, 179, 211, 204, 157, 91, 37, 24, 60, 133, 210, 253, 244, 176, 79, 7, 1, 18, 
116, 230, 255, 255, 220, 88, 1, 1, 1, 79, 226, 255, 255, 248, 113, 1, 1, 1, 41, 215, 
255, 255, 255, 143, 1, 1, 1, 25, 204, 255, 255, 255, 164, 4, 1, 1, 17, 188, 255, 255, 
255, 175, 15, 1, 1, 16, 167, 255, 255, 255, 185, 33, 1, 1, 13, 129, 241, 255, 255, 213, 
95, 8, 1, 1, 70, 181, 254, 255, 249, 164, 46, 1, 1, 18, 134, 245, 255, 255, 201, 49, 
1, 1, 9, 142, 255, 255, 255, 179, 24, 1, 1, 32, 192, 255, 255, 247, 120, 4, 1, 1, 
89, 221, 255, 255, 202, 90, 10, 1, 34, 118, 198, 240, 229, 174, 105, 50, 33, 59, 115, 174, 
210, 205, 163, 106, 63, 56, 86, 134, 173, 183, 162, 127, 102, 99, 114, 135, 152, 161, 162, 157, 
145, 125, 99, 73, 60, 70, 105, 153, 195, 208, 187, 140, 94, 72, 87, 126, 165, 178, 155, 108, 
64, 50, 76, 128, 180, 206, 197, 162, 123, 99, 96, 106, 116, 117, 112, 109, 115, 131, 146, 153, 
147, 135, 129, 135, 147, 153, 142, 113, 80, 64, 76, 113, 156, 183, 182, 160, 132, 117, 119, 132, 
149, 158, 152, 130, 101, 77, 69, 82, 111, 147, 175, 186, 177, 153, 123, 100, 91, 97, 114, 132, 
144, 145, 136, 124, 114, 113, 119, 131, 142, 147, 143, 133, 121, 114, 114, 122, 133, 142, 144, 138, 
124, 110, 101, 101, 112, 130, 149, 162, 166, 158, 141, 122, 104, 94, 92, 98, 110, 124, 137, 148, 
156, 160, 160, 154, 143, 126, 107, 90, 80, 80, 92, 115, 144, 170, 188, 191, 177, 151, 119, 88, 
68, 62, 72, 95, 125, 156, 179, 191, 188, 172, 147, 117, 89, 70, 64, 72, 93, 123, 156, 182, 
196, 194, 174, 143, 107, 77, 59, 59, 77, 108, 144, 175, 193, 194, 178, 149, 117, 88, 71, 69, 
82, 106, 135, 161, 177, 180, 170, 149, 123, 100, 86, 83, 92, 111, 133, 152, 164, 165, 155, 139, 
121, 106, 99, 101, 111, 125, 139, 147, 148, 142, 132, 121, 114, 114, 119, 129, 139, 144, 142, 133, 
121, 109, 104, 108, 120, 138, 154, 163, 160, 146, 123, 100, 83, 81, 94, 120, 151, 177, 189, 182, 
156, 119, 82, 58, 56, 77, 117, 162, 199, 215, 202, 164, 112, 62, 33, 34, 67, 122, 181, 224, 
236, 213, 159, 94, 38, 12, 24, 72, 141, 207, 247, 246, 205, 136, 63, 12, 2, 34, 100, 177, 
237, 255, 234, 172, 93, 27, 1, 14, 72, 150, 220, 254, 244, 191, 114, 44, 6, 14, 64, 137, 
205, 243, 236, 189, 120, 55, 21, 29, 75, 140, 197, 225, 214, 169, 109, 60, 41, 58, 103, 156, 
195, 203, 178, 133, 88, 63, 71, 108, 154, 187, 189, 157, 107, 66, 55, 84, 140, 196, 222, 201, 
139, 63, 12, 14, 73, 167, 245, 255, 239, 141, 27, 1, 1, 42, 175, 255, 255, 255, 160, 23, 
1, 1, 22, 167, 255, 255, 255, 183, 28, 1, 1, 11, 148, 255, 255, 255, 200, 41, 1, 1, 
8, 123, 242, 255, 255, 211, 88, 4, 1, 9, 90, 192, 253, 255, 225, 141, 57, 6, 4, 47, 
126, 207, 252, 251, 200, 112, 26, 1, 5, 75, 182, 255, 255, 239, 133, 20, 1, 1, 62, 200, 
255, 255, 237, 107, 1, 1, 1, 99, 234, 255, 255, 199, 54, 1, 1, 30, 161, 254, 255, 236, 
128, 22, 1, 17, 105, 197, 244, 227, 162, 89, 46, 51, 94, 145, 177, 179, 155, 125, 106, 104, 
113, 124, 130, 130, 129, 132, 137, 142, 139, 129, 115, 107, 109, 121, 136, 148, 150, 143, 130, 117, 
108, 107, 114, 127, 143, 155, 156, 143, 120, 97, 87, 99, 130, 163, 179, 166, 128, 88, 70, 87, 
129, 171, 186, 165, 121, 82, 74, 101, 144, 174, 171, 138, 101, 84, 100, 136, 165, 165, 137, 101, 
86, 102, 139, 169, 169, 138, 98, 79, 94, 134, 171, 177, 149, 107, 80, 88, 123, 160, 172, 153, 
118, 93, 96, 121, 149, 158, 144, 119, 102, 107, 128, 148, 152, 136, 115, 104, 111, 131, 148, 149, 
136, 118, 109, 113, 127, 139, 142, 136, 126, 119, 119, 124, 129, 133, 133, 131, 128, 124, 122, 124, 
129, 134, 136, 131, 122, 117, 121, 131, 141, 141, 129, 115, 109, 119, 137, 149, 145, 126, 108, 106, 
122, 144, 153, 141, 118, 103, 110, 132, 152, 150, 129, 106, 101, 120, 147, 158, 143, 115, 98, 106, 
133, 156, 154, 130, 104, 100, 120, 147, 157, 140, 113, 100, 111, 138, 155, 148, 123, 103, 105, 127, 
150, 152, 133, 111, 104, 119, 141, 150, 138, 118, 108, 117, 135, 146, 140, 123, 111, 115, 130, 142, 
141, 129, 117, 116, 125, 136, 138, 131, 122, 120, 124, 131, 134, 131, 126, 124, 125, 128, 131, 131, 
130, 128, 126, 124, 125, 129, 132, 132, 129, 124, 122, 127, 134, 136, 129, 121, 118, 125, 136, 140, 
132, 120, 115, 123, 137, 142, 133, 119, 113, 123, 139, 144, 133, 116, 110, 123, 141, 147, 134, 115, 
110, 123, 142, 146, 131, 112, 109, 126, 146, 147, 129, 110, 109, 128, 146, 145, 126, 109, 111, 131, 
154, 166, 160, 144, 126, 110, 95, 83, 80, 96, 131, 170, 192, 186, 157, 124, 103, 96, 97, 99, 
103, 115, 134, 152, 158, 149, 136, 130, 135, 140, 135, 117, 97, 89, 98, 117, 134, 145, 153, 162, 
167, 159, 135, 102, 80, 79, 97, 119, 135, 144, 151, 160, 163, 154, 132, 109, 98, 101, 110, 115, 
114, 117, 129, 149, 172, 188, 187, 166, 129, 86, 52, 39, 53, 91, 141, 188, 215, 217, 193, 152, 
107, 72, 56, 59, 79, 107, 136, 159, 172, 177, 173, 163, 147, 128, 106, 86, 73, 71, 82, 108, 
141, 174, 197, 202, 187, 154, 114, 76, 53, 51, 69, 103, 142, 176, 196, 198, 182, 154, 122, 94, 
74, 68, 75, 93, 118, 145, 168, 183, 186, 175, 154, 125, 96, 73, 63, 69, 91, 123, 157, 184, 
197, 191, 169, 136, 100, 73, 60, 65, 86, 118, 151, 177, 190, 187, 170, 144, 114, 88, 73, 70, 
82, 104, 132, 160, 179, 186, 179, 159, 131, 102, 79, 68, 73, 92, 121, 151, 176, 188, 184, 166, 
137, 107, 82, 70, 73, 90, 117, 146, 170, 182, 181, 166, 142, 115, 91, 78, 77, 89, 111, 137, 
161, 176, 179, 168, 148, 122, 98, 82, 78, 87, 107, 132, 156, 172, 177, 169, 150, 125, 102, 86, 
81, 88, 106, 129, 152, 168, 173, 166, 150, 127, 106, 90, 85, 91, 107, 128, 149, 164, 169, 164, 
149, 129, 109, 94, 88, 94, 108, 128, 147, 161, 166, 160, 146, 128, 109, 96, 92, 98, 111, 129, 
146, 158, 162, 156, 144, 127, 111, 99, 96, 101, 114, 130, 145, 155, 158, 152, 140, 125, 111, 102, 
100, 107, 118, 132, 145, 152, 152, 146, 135, 123, 112, 106, 106, 113, 123, 134, 143, 147, 146, 140, 
131, 121, 114, 111, 112, 118, 126, 135, 141, 143, 141, 136, 128, 121, 117, 115, 117, 122, 129, 134, 
138, 138, 136, 131, 126, 122, 119, 120, 123, 128, 132, 134, 133, 130, 124, 120, 120, 123, 131, 139, 
144, 143, 135, 123, 109, 101, 101, 112, 131, 151, 166, 169, 157, 134, 105, 82, 73, 83, 108, 143, 
174, 192, 190, 166, 128, 88, 60, 53, 70, 107, 152, 191, 210, 203, 172, 126, 79, 47, 40, 62, 
104, 155, 198, 220, 213, 179, 128, 77, 41, 32, 53, 98, 153, 201, 227, 221, 185, 129, 72, 32, 
22, 48, 101, 164, 217, 241, 227, 180, 113, 50, 13, 14, 54, 120, 190, 239, 250, 220, 157, 85, 
26, 2, 22, 77, 151, 216, 252, 245, 198, 127, 56, 10, 5, 41, 107, 180, 235, 253, 228, 170, 
97, 35, 5, 17, 66, 137, 204, 245, 246, 207, 141, 71, 20, 6, 33, 93, 165, 224, 251, 235, 
183, 111, 45, 8, 11, 55, 124, 195, 243, 251, 216, 151, 77, 21, 2, 27, 87, 162, 225, 254, 
239, 185, 111, 43, 5, 9, 55, 128, 200, 247, 251, 213, 145, 71, 16, 2, 32, 96, 171, 230, 
254, 233, 174, 100, 36, 4, 17, 68, 141, 209, 248, 244, 199, 129, 59, 14, 9, 47, 113, 185, 
236, 248, 218, 155, 83, 27, 8, 31, 89, 161, 221, 247, 230, 177, 106, 43, 11, 21, 70, 139, 
204, 242, 238, 194, 126, 60, 18, 16, 55, 121, 188, 234, 240, 205, 142, 75, 27, 16, 47, 107, 
174, 224, 238, 212, 155, 88, 37, 19, 42, 97, 162, 214, 234, 214, 162, 99, 47, 25, 42, 91, 
152, 204, 227, 213, 167, 107, 56, 32, 45, 88, 145, 195, 219, 209, 168, 113, 65, 41, 50, 88, 
141, 187, 211, 202, 166, 116, 71, 50, 58, 93, 140, 182, 202, 194, 161, 116, 77, 59, 67, 98, 
140, 176, 193, 184, 154, 114, 82, 68, 78, 107, 143, 172, 183, 172, 145, 112, 86, 78, 90, 116, 
146, 168, 172, 159, 134, 108, 91, 89, 104, 127, 150, 162, 160, 144, 122, 104, 97, 103, 120, 140, 
153, 155, 144, 127, 110, 102, 106, 120, 137, 150, 153, 144, 127, 110, 101, 104, 119, 139, 155, 159, 
149, 128, 107, 93, 95, 112, 137, 160, 170, 162, 139, 109, 85, 79, 94, 125, 159, 182, 183, 160, 
122, 84, 63, 68, 100, 146, 186, 204, 190, 149, 97, 55, 43, 66, 117, 175, 215, 220, 186, 126, 
64, 26, 31, 77, 146, 211, 243, 228, 169, 90, 25, 1, 30, 102, 188, 248, 255, 220, 134, 43, 
1, 3, 68, 174, 251, 255, 239, 140, 26, 1, 1, 21, 132, 237, 255, 255, 193, 79, 3, 1, 
21, 128, 236, 255, 255, 228, 104, 7, 1, 1, 48, 170, 252, 255, 242, 145, 30, 1, 1, 35, 
158, 252, 255, 255, 217, 88, 1, 1, 1, 80, 199, 255, 255, 228, 112, 11, 1, 1, 42, 172, 
255, 255, 255, 199, 74, 1, 1, 35, 139, 233, 255, 240, 153, 45, 1, 1, 8, 90, 190, 250, 
255, 218, 144, 77, 48, 68, 126, 192, 237, 237, 192, 119, 47, 6, 6, 47, 108, 162, 189, 181, 
147, 106, 81, 85, 117, 165, 208, 227, 213, 173, 121, 76, 55, 60, 86, 117, 139, 142, 127, 102, 
83, 79, 97, 131, 169, 197, 206, 194, 166, 135, 111, 101, 105, 118, 128, 129, 119, 100, 82, 72, 
77, 97, 125, 154, 174, 180, 174, 160, 146, 137, 135, 138, 142, 141, 132, 115, 96, 80, 73, 78, 
93, 113, 133, 147, 153, 153, 151, 149, 150, 154, 158, 159, 153, 140, 123, 105, 90, 83, 84, 92, 
103, 115, 124, 130, 134, 139, 144, 152, 160, 165, 166, 161, 149, 134, 119, 106, 97, 94, 95, 99, 
104, 108, 113, 119, 127, 136, 147, 157, 163, 166, 163, 155, 144, 132, 121, 112, 106, 102, 100, 100, 
101, 104, 109, 117, 128, 139, 149, 157, 161, 161, 157, 150, 142, 132, 124, 116, 110, 104, 101, 99, 
100, 104, 111, 120, 131, 141, 150, 155, 157, 156, 152, 146, 140, 132, 125, 117, 110, 105, 101, 100, 
103, 109, 116, 126, 135, 143, 148, 152, 153, 152, 148, 143, 137, 129, 122, 115, 109, 105, 103, 105, 
109, 115, 122, 130, 137, 143, 147, 149, 149, 147, 143, 138, 132, 125, 118, 113, 109, 107, 108, 111, 
116, 122, 128, 134, 139, 143, 145, 146, 145, 142, 137, 132, 126, 120, 115, 112, 111, 112, 115, 119, 
123, 128, 133, 137, 140, 141, 142, 141, 138, 135, 130, 126, 122, 119, 119, 121, 125, 129, 132, 132, 
131, 129, 126, 124, 123, 124, 125, 127, 128, 129, 130, 132, 133, 135, 137, 137, 136, 133, 128, 122, 
116, 112, 111, 112, 116, 121, 127, 133, 139, 143, 147, 148, 148, 144, 139, 131, 122, 114, 106, 101, 
100, 103, 109, 118, 129, 139, 149, 155, 159, 158, 154, 147, 137, 126, 114, 104, 96, 93, 95, 104, 
117, 131, 145, 155, 161, 162, 158, 151, 141, 131, 120, 109, 101, 95, 93, 96, 104, 116, 131, 146, 
159, 166, 168, 163, 153, 140, 125, 112, 100, 93, 90, 92, 99, 110, 123, 138, 152, 163, 169, 169, 
163, 151, 135, 118, 103, 92, 86, 87, 93, 104, 119, 135, 150, 162, 169, 170, 166, 156, 141, 124, 
108, 94, 85, 83, 88, 99, 114, 132, 149, 162, 170, 172, 167, 157, 142, 125, 109, 95, 86, 83, 
87, 98, 113, 131, 149, 163, 172, 174, 168, 156, 140, 122, 106, 93, 85, 84, 90, 102, 117, 135, 
151, 164, 171, 172, 165, 152, 136, 118, 102, 90, 84, 86, 94, 108, 125, 142, 157, 167, 171, 167, 
157, 142, 126, 110, 97, 89, 87, 93, 104, 119, 135, 150, 162, 167, 166, 158, 146, 130, 115, 102, 
94, 91, 95, 104, 117, 132, 146, 156, 162, 161, 155, 145, 132, 118, 106, 99, 96, 99, 107, 119, 
132, 143, 152, 156, 155, 150, 140, 129, 118, 110, 104, 103, 107, 114, 123, 133, 141, 147, 149, 148, 
143, 135, 126, 118, 113, 110, 111, 115, 121, 128, 135, 139, 142, 141, 138, 134, 129, 124, 120, 118, 
119, 121, 124, 128, 131, 133, 134, 133, 131, 129, 127, 126, 125, 126, 127, 129, 130, 131, 131, 129, 
126, 124, 122, 122, 123, 126, 130, 133, 137, 138, 138, 135, 130, 124, 119, 114, 113, 114, 119, 126, 
134, 141, 147, 148, 146, 139, 129, 119, 109, 104, 103, 107, 117, 129, 142, 152, 158, 157, 150, 138, 
124, 109, 98, 93, 95, 105, 120, 138, 153, 164, 167, 162, 149, 131, 112, 96, 86, 86, 94, 111, 
131, 152, 168, 175, 172, 159, 139, 116, 95, 81, 77, 85, 102, 126, 151, 171, 182, 180, 167, 144, 
117, 93, 76, 71, 79, 98, 125, 152, 175, 187, 185, 169, 144, 115, 88, 71, 67, 77, 100, 129, 
158, 180, 190, 185, 166, 138, 108, 82, 67, 67, 82, 107, 138, 167, 185, 190, 180, 157, 127, 97, 
75, 67, 73, 93, 122, 152, 171, 173, 158, 134, 108, 91, 84, 88, 98, 109, 117, 120, 123, 127, 
136, 148, 160, 166, 164, 152, 134, 115, 102, 101, 113, 133, 155, 170, 171, 158, 134, 105, 81, 68, 
69, 83, 106, 129, 148, 158, 159, 153, 143, 132, 124, 120, 120, 123, 129, 137, 146, 154, 159, 158, 
150, 136, 117, 97, 82, 75, 80, 96, 119, 141, 152, 148, 131, 109, 93, 89, 100, 120, 143, 158, 
162, 153, 136, 121, 112, 115, 126, 141, 152, 154, 146, 132, 116, 105, 104, 111, 123, 134, 140, 139, 
131, 121, 113, 111, 116, 126, 137, 144, 145, 139, 131, 122, 118, 118, 124, 131, 137, 139, 136, 130, 
123, 119, 119, 123, 130, 136, 138, 137, 133, 126, 121, 119, 121, 124, 128, 131, 131, 128, 124, 120, 
119, 120, 125, 130, 135, 138, 138, 137, 134, 132, 132, 132, 134, 135, 134, 131, 126, 121, 117, 114, 
114, 116, 118, 121, 123, 124, 125, 126, 129, 132, 137, 141, 145, 146, 145, 142, 138, 134, 129, 126, 
123, 121, 118, 115, 112, 109, 109, 110, 113, 118, 124, 130, 136, 140, 144, 146, 148, 149, 148, 147, 
144, 139, 133, 126, 119, 113, 108, 105, 104, 104, 106, 110, 114, 120, 126, 133, 140, 147, 152, 155, 
156, 155, 151, 146, 140, 132, 125, 117, 111, 105, 101, 98, 98, 101, 105, 112, 121, 130, 138, 146, 
152, 157, 159, 159, 157, 152, 146, 138, 129, 120, 111, 103, 97, 94, 94, 97, 102, 110, 119, 128, 
138, 147, 154, 159, 162, 162, 159, 154, 147, 137, 127, 117, 108, 100, 95, 92, 93, 97, 104, 112, 
122, 133, 143, 152, 158, 162, 163, 161, 157, 149, 140, 130, 120, 110, 102, 96, 93, 93, 97, 103, 
112, 122, 133, 143, 152, 158, 161, 162, 159, 154, 146, 137, 127, 117, 108, 101, 96, 95, 96, 102, 
109, 118, 129, 138, 147, 153, 157, 158, 156, 152, 146, 138, 129, 120, 112, 105, 101, 101, 105, 112, 
121, 130, 137, 142, 144, 144, 143, 141, 139, 136, 132, 128, 124, 120, 117, 116, 118, 121, 125, 129, 
132, 133, 132, 131, 128, 127, 126, 126, 126, 127, 129, 130, 131, 133, 135, 136, 137, 136, 133, 129, 
124, 118, 113, 110, 110, 112, 117, 123, 131, 138, 144, 149, 151, 151, 149, 143, 135, 125, 115, 106, 
100, 98, 101, 109, 121, 133, 144, 152, 157, 157, 155, 149, 141, 131, 121, 110, 101, 95, 93, 97, 
106, 118, 133, 148, 159, 166, 167, 161, 151, 139, 124, 111, 100, 93, 90, 92, 99, 111, 126, 142, 
156, 167, 171, 169, 160, 146, 129, 113, 98, 89, 85, 88, 97, 110, 126, 143, 157, 167, 171, 168, 
159, 145, 128, 112, 97, 88, 85, 89, 100, 115, 132, 148, 161, 168, 169, 163, 151, 136, 120, 105, 
95, 90, 91, 99, 111, 126, 141, 153, 161, 164, 160, 150, 138, 124, 111, 101, 97, 98, 104, 114, 
126, 138, 148, 153, 154, 151, 143, 133, 123, 114, 108, 107, 109, 115, 123, 131, 137, 142, 143, 141, 
138, 132, 127, 122, 119, 119, 120, 124, 127, 131, 132, 133, 131, 128, 126, 124, 124, 125, 128, 132, 
135, 137, 137, 134, 130, 123, 118, 113, 112, 115, 120, 128, 137, 145, 150, 151, 146, 137, 125, 113, 
103, 97, 99, 107, 121, 137, 152, 162, 166, 161, 148, 131, 111, 95, 86, 85, 94, 112, 133, 155, 
170, 177, 173, 158, 136, 112, 90, 77, 75, 85, 106, 132, 158, 178, 186, 181, 163, 136, 108, 83, 
70, 70, 84, 109, 138, 166, 184, 189, 179, 156, 127, 98, 76, 67, 74, 93, 121, 151, 175, 187, 
184, 166, 140, 110, 86, 73, 74, 90, 115, 143, 166, 179, 178, 163, 140, 114, 94, 83, 85, 99, 
120, 142, 158, 166, 162, 149, 131, 114, 102, 99, 105, 117, 131, 142, 148, 147, 140, 129, 120, 114, 
115, 120, 129, 137, 142, 140, 133, 122, 113, 109, 112, 122, 136, 150, 158, 155, 143, 123, 103, 89, 
87, 99, 122, 150, 173, 183, 175, 151, 116, 83, 63, 63, 85, 123, 165, 198, 209, 193, 155, 105, 
61, 37, 43, 78, 131, 186, 223, 229, 201, 147, 85, 36, 17, 35, 86, 153, 213, 245, 237, 191, 
122, 54, 11, 9, 48, 117, 190, 242, 253, 220, 154, 77, 19, 1, 28, 92, 169, 231, 254, 231, 
169, 93, 31, 6, 28, 86, 160, 219, 243, 226, 181, 126, 83, 65, 74, 101, 132, 153, 158, 148, 
129, 110, 98, 97, 103, 113, 123, 131, 138, 146, 155, 164, 167, 162, 147, 123, 99, 83, 82, 97, 
124, 151, 166, 162, 138, 104, 74, 63, 78, 117, 167, 208, 225, 209, 163, 106, 57, 37, 53, 98, 
154, 196, 207, 180, 126, 67, 28, 28, 69, 138, 208, 250, 250, 210, 148, 90, 58, 62, 95, 138, 
170, 175, 150, 106, 63, 40, 47, 83, 134, 181, 208, 206, 181, 144, 112, 97, 104, 125, 149, 162, 
156, 133, 102, 74, 61, 70, 96, 130, 160, 176, 174, 159, 138, 121, 116, 122, 136, 149, 153, 145, 
128, 106, 89, 84, 91, 109, 131, 149, 157, 154, 143, 130, 122, 120, 125, 135, 142, 144, 138, 127, 
115, 106, 105, 111, 123, 135, 143, 145, 139, 131, 122, 117, 117, 122, 130, 136, 138, 137, 132, 127, 
124, 124, 128, 132, 135, 135, 131, 124, 116, 111, 109, 113, 121, 130, 138, 143, 146, 145, 142, 139, 
135, 132, 128, 124, 118, 112, 106, 104, 105, 111, 121, 133, 145, 154, 158, 158, 153, 145, 135, 125, 
115, 107, 101, 98, 98, 102, 110, 121, 135, 148, 159, 166, 166, 161, 150, 136, 120, 106, 96, 90, 
90, 95, 105, 118, 132, 147, 159, 167, 169, 165, 155, 141, 124, 108, 95, 87, 86, 91, 102, 118, 
135, 151, 163, 169, 169, 162, 149, 134, 118, 104, 94, 89, 91, 98, 111, 126, 141, 154, 163, 165, 
161, 151, 138, 123, 110, 100, 96, 97, 104, 114, 127, 139, 148, 154, 155, 151, 143, 133, 123, 114, 
109, 107, 110, 115, 123, 131, 137, 141, 142, 140, 136, 130, 125, 122, 120, 121, 124, 127, 131, 132, 
132, 130, 127, 124, 121, 121, 123, 126, 131, 136, 140, 142, 140, 136, 128, 120, 112, 107, 106, 110, 
119, 131, 143, 153, 158, 157, 149, 136, 120, 104, 94, 90, 95, 108, 126, 145, 162, 172, 172, 162, 
144, 120, 97, 80, 73, 80, 99, 127, 157, 181, 192, 187, 166, 134, 100, 73, 61, 67, 89, 121, 
155, 181, 192, 185, 163, 132, 102, 80, 73, 82, 102, 129, 153, 168, 170, 160, 142, 121, 105, 98, 
101, 113, 129, 143, 149, 147, 137, 123, 111, 106, 111, 123, 140, 154, 160, 155, 138, 114, 92, 80, 
83, 103, 133, 165, 188, 192, 174, 138, 96, 61, 47, 60, 98, 148, 194, 220, 216, 181, 126, 70, 
31, 24, 53, 109, 173, 224, 243, 222, 168, 99, 39, 8, 19, 68, 139, 208, 249, 248, 204, 133, 
59, 10, 4, 41, 111, 187, 241, 253, 221, 154, 78, 21, 4, 34, 98, 173, 229, 246, 218, 156, 
85, 32, 18, 47, 107, 173, 219, 226, 195, 137, 79, 43, 44, 81, 135, 184, 206, 193, 152, 102, 
66, 60, 87, 132, 175, 194, 180, 140, 92, 61, 63, 98, 151, 196, 209, 184, 128, 67, 31, 40, 
92, 166, 228, 247, 211, 134, 47, 1, 4, 64, 163, 245, 255, 246, 159, 45, 1, 1, 26, 144, 
246, 255, 255, 192, 58, 1, 1, 8, 117, 238, 255, 255, 221, 83, 1, 1, 1, 90, 222, 255, 
255, 233, 115, 12, 1, 1, 65, 181, 254, 255, 241, 152, 52, 1, 1, 41, 129, 214, 255, 250, 
195, 110, 34, 1, 12, 76, 163, 238, 255, 237, 158, 63, 3, 1, 38, 137, 235, 255, 251, 174, 
64, 1, 1, 37, 144, 239, 255, 242, 154, 52, 1, 7, 72, 165, 233, 243, 197, 123, 60, 37, 
61, 112, 163, 188, 181, 152, 119, 99, 97, 107, 121, 132, 137, 139, 140, 140, 137, 129, 118, 110, 
109, 117, 129, 142, 148, 146, 137, 127, 117, 110, 108, 113, 126, 142, 156, 159, 145, 120, 94, 84, 
98, 131, 165, 179, 164, 126, 90, 77, 95, 132, 164, 171, 151, 118, 96, 98, 120, 144, 152, 140, 
119, 107, 113, 133, 151, 150, 132, 109, 98, 108, 132, 154, 158, 143, 119, 104, 105, 119, 136, 145, 
143, 134, 124, 119, 119, 123, 128, 132, 134, 133, 129, 125, 122, 125, 131, 134, 131, 123, 117, 120, 
132, 143, 144, 131, 114, 105, 114, 134, 150, 149, 131, 111, 106, 119, 139, 148, 139, 120, 109, 116, 
134, 148, 143, 125, 108, 108, 125, 144, 149, 137, 119, 110, 118, 132, 140, 136, 126, 119, 122, 130, 
136, 134, 127, 121, 122, 126, 131, 134, 133, 130, 129, 136, 148, 157, 151, 129, 100, 80, 80, 100, 
129, 152, 163, 164, 158, 150, 136, 117, 97, 85, 89, 109, 134, 151, 153, 146, 138, 137, 139, 138, 
128, 113, 103, 103, 112, 121, 127, 131, 138, 151, 161, 161, 144, 118, 96, 88, 95, 110, 123, 135, 
147, 160, 167, 160, 139, 113, 95, 92, 101, 114, 123, 131, 142, 155, 166, 171, 166, 149, 124, 96};


SoftwareSerial mySerial[4] = {SoftwareSerial(RX_1,TX_1),SoftwareSerial(RX_2,TX_2),SoftwareSerial(RX_3,TX_3),SoftwareSerial(RX_4,TX_4)};

int active_channel;
int listen_count;
int state;
uint8_t read_buf[MAX_BUFFER_SIZE];
uint8_t write_buf[MAX_BUFFER_SIZE];
int read_buf_len, write_buf_len;
long waitTime;
uint8_t myID;
int next_available_ID;
long prevTime;
long startTime;
int ledState = LOW;
int port_map[4];
int return_path[16];
int return_path_len;
int next_list[4];
int next_list_len;
int sensorThreshold;
int sensor_flag;
int auto_setup;
long start_lock;
uint8_t randNumber;
long playback_started;
int waitForPlayback = 0;



void blink_led(int ledPin){
  long blinkTime = 250;
  long curTime = millis();
  if((curTime - prevTime) > blinkTime){
    prevTime = curTime;
    if(ledState == LOW){
      ledState = HIGH;
    }else{
      ledState = LOW;
    }
  }
  digitalWrite(ledPin, ledState);
}

int isvalueinarray(int val, int *arr, int size){
    int i;
    for (i=0; i < size; i++) {
        if (arr[i] == val)
            return i;
    }
    return -1;
}

//Write message buffer to serial TX
void writebuffertoserial(int channel, uint8_t *arr, int buf_size) {
  int i;
  int temp_len = buf_size;
  uint8_t temp_buf[buf_size+1];
  const uint8_t start_sig = COM;
  while(temp_len > 0){
    temp_buf[temp_len] = arr[temp_len-1];
    temp_len--;
  }
  temp_buf[0] = start_sig;
  Serial.print("Writing");
  for(i=0;i<buf_size+1;i++){
    Serial.print(", ");
    Serial.print(temp_buf[i], DEC);
  }
  Serial.print(" to serial channel ");
  Serial.println(channel, DEC);
  if(channel > 0 && channel < 5){
    mySerial[channel-1].write(temp_buf, buf_size+1);
  }else{
    Serial.println("Invalid channel selection for writebuffertoserial()");
    Serial.print("Error! cannot write to serial channel ");
    Serial.println(channel);
  }
}

int setChannel(int channel){
    if(channel > 0 && channel < 5){
        mySerial[channel-1].listen();
        delay(100);
        active_channel = channel;
        return 0;
    }else{
        return -1;
    }
}

void set_ID(){
  int send_status = -1;
  /*for(int i=0;i<read_buf_len;i++){
    Serial.print(read_buf[i]);
  }
  Serial.println("");*/
  myID = read_buf[1];
  write_buf[0] = IDSET;
  write_buf[1] = myID;
  write_buf_len = 2;
  send_status = send_msg();
  if(send_status != 0){
    Serial.print("Error: status code = ");
    Serial.print(send_status);
    Serial.println(". Something went wrong with board-to-board comms!!!");
  }else{
    state = LISTENING;
  }
}

void set_neighbors(){
  int send_status = -1;
  return_path_len = 0;
  next_available_ID = read_buf[1];
  for(int j=2;j<read_buf_len;j++){
    return_path[j-2] = read_buf[j];
    Serial.println(return_path[return_path_len]);
    return_path_len++;
  }
  for(int i=0;i<4;i++){
    setChannel(i+1);
    port_map[i] = get_ID();
    if(port_map[i] == NO_RESPONSE){
      port_map[i] = -1;
    }else if(port_map[i] == 255 || port_map[i] >= next_available_ID){  // next_available_ID){ This should fix the issue of having previously assigned IDs during testing
      port_map[i] = send_set_ID();
      if(port_map[i] >= next_available_ID){
        next_available_ID = port_map[i] + 1;
      }
    }
  }
  //find port with ID '0'
  int port_num = 0; //invalid port number
  for(int i=0;i<4;i++){
    if(port_map[i] == return_path[0]){
      port_num = i+1;
    }
  }
  if(port_num == 0){
    Serial.println("no valid port found!");
  }else{
    setChannel(port_num);
  }
  write_buf_len = 0;
  for(int i=1;i<return_path_len;i++){
    write_buf[write_buf_len] = return_path[i];
    write_buf_len++;
  }
  write_buf[write_buf_len] = NEIGHBORSSET;
  write_buf_len++;
  write_buf[write_buf_len] = myID;
  write_buf_len++;
  write_buf[write_buf_len] = port_map[0];
  write_buf_len++;
  write_buf[write_buf_len] = port_map[1];
  write_buf_len++;
  write_buf[write_buf_len] = port_map[2];
  write_buf_len++;
  write_buf[write_buf_len] = port_map[3];
  write_buf_len++;
  write_buf[write_buf_len] = next_available_ID;
  write_buf_len++;
  
  send_status = send_msg();
  if(send_status != 0){
    Serial.print("Error: status code = ");
    Serial.print(send_status);
    Serial.println(". Something went wrong with board-to-board comms!!!");
  }else{
    state = LISTENING;
  }
}

int send_set_ID(){
  int send_status = -1;
  write_buf[0] = SETID;
  write_buf[1] = next_available_ID;
  write_buf_len = 2;
  send_status = send_msg();
  if(send_status != 0){
    //something went wrong with board to board comms
    Serial.print("Error: status code = ");
    Serial.print(send_status);
    Serial.println(". Something went wrong with board-to-board comms!!!");
    return -1;
  }else{
    //wait for confirmation
    int recvd = 0;
    while(recvd == 0){
      delay(1);
      if(mySerial[active_channel-1].read() == COM){
        Serial.println("COM");
        //uint8_t cur_read = -1;
        int cnt = 0;
        while(mySerial[active_channel-1].available() > 0 && cnt < MAX_BUFFER_SIZE && mySerial[active_channel-1].peek() != COM){
          read_buf[cnt] = mySerial[active_channel-1].read();
          cnt++;
          Serial.println("available");
          delay(1);
        }
        read_buf_len = cnt;
      }    
      if(read_buf_len > 0 && read_buf[0] == IDSET){
        send_msg_received();
        recvd = 1;
      }
    }
    return read_buf[1];
  }
}

int get_ID(){
  int send_status = -1;
  write_buf[0] = SENDID;
  write_buf_len = 1;
  send_status = send_msg();
  if(send_status != 0){
  //something went wrong with board to board comms
    Serial.print("Error: status code = ");
    Serial.print(send_status);
    Serial.println(". Something went wrong with board-to-board comms!!!");
    return NO_RESPONSE;
  }else{
    //wait for response
    int recvd = 0;
    while(recvd == 0){
      delay(1);
      if(mySerial[active_channel-1].read() == COM){
        Serial.println("COM");
        //uint8_t cur_read = -1;
        int cnt = 0;
        while(mySerial[active_channel-1].available() > 0 && cnt < MAX_BUFFER_SIZE && mySerial[active_channel-1].peek() != COM){
          read_buf[cnt] = mySerial[active_channel-1].read();
          cnt++;
          Serial.println("available");
          delay(1);
        }
        read_buf_len = cnt;
      }    
      if(read_buf_len > 0){
        send_msg_received();
        recvd = 1;
      }
    }
    return read_buf[0];
  }
}

void send_ID(){
    int send_status = -1;
    write_buf[0] = myID;
    write_buf_len = 1;
    send_status = send_msg();
    if(send_status != 0){
        //something went wrong with board to board comms
        Serial.print("Error: status code = ");
        Serial.print(send_status);
        Serial.println(". Something went wrong with board-to-board comms!!!");
    }else{
      state = LISTENING;
    }
    //writebuffertoserial(active_channel, write_buf, write_buf_len);
}

int send_msg(){
  int count = 0;
  int confirm_rcvd = 0;
  int temp_buf_len = 0;
  uint8_t temp_buf[MAX_BUFFER_SIZE];
  while(mySerial[active_channel-1].available() > 0)mySerial[active_channel-1].read();
  while(confirm_rcvd != 1 && count < TIME_OUT){
    writebuffertoserial(active_channel, write_buf, write_buf_len);
    delay(30);
    if(mySerial[active_channel-1].read() == COM){
        int cnt = 0;
        while(mySerial[active_channel-1].available() > 0 && mySerial[active_channel-1].peek() != COM){
            temp_buf[cnt] = mySerial[active_channel-1].read();
            cnt++;
        }
        temp_buf_len = cnt;
        if(cnt > 0 && temp_buf[cnt-1] == ROGER){
          confirm_rcvd = 1;
          Serial.println("...");
        }else{
          while(mySerial[active_channel-1].available() > 0)mySerial[active_channel].read();
        }
    }else{
        //if the input buffer doesn't start with '170', flush the garbage.
        while(mySerial[active_channel-1].available() > 0)mySerial[active_channel-1].read();
    }
    count++;
  }
  delay(60);
  while(mySerial[active_channel-1].available() > 0)mySerial[active_channel-1].read();
  read_buf_len = 0;
  
  if(count > TIME_OUT || temp_buf_len <= 0){
    return -1;
  }else{
    return 0;
  }
}

void send_msg_received(){
    uint8_t msg_rcvd = ROGER;
    for(int i=0;i<2;i++){
        writebuffertoserial(active_channel, &msg_rcvd, 1);
        delayMicroseconds(500);
    }
    //returning with the assumption that our confirmation was received
}

void setup(){
  Serial.begin(TERMBAUD);
  Serial.println("attempting to initialize Serial comms...");
  Serial.println("...");
  pinMode(RX_1, INPUT_PULLUP);
  pinMode(TX_1, OUTPUT);
  pinMode(RX_2, INPUT_PULLUP);
  pinMode(TX_2, OUTPUT);
  pinMode(RX_3, INPUT_PULLUP);
  pinMode(TX_3, OUTPUT);
  pinMode(RX_4, INPUT_PULLUP);
  pinMode(TX_4, OUTPUT);
  pinMode(SENSORPIN, INPUT);
  pinMode(SPKRPIN, OUTPUT);
  for(int i=3;i>=0;i--){
    mySerial[i].begin(TRXRATE);
    Serial.println("...");
  }
  pinMode(LEDPIN, OUTPUT);
  Serial.println("...initialization complete.");
  randomSeed(analogRead(SEEDPIN));
  sensor_flag = 0;
  myID = -1;
  active_channel = 1;
  listen_count = 1;
  next_available_ID = -1;
  next_list_len =0;
  sensorThreshold = 200;
  waitTime = 20;
  read_buf_len = write_buf_len = 0;
  for(int i=0;i<4;i++){
    port_map[i] = -1;
  }
  for(int i=0;i<16;i++){
    return_path[i] = -1;
  }
  return_path_len = 0;
  state = LISTENING;
  digitalWrite(LEDPIN, LOW);
  prevTime = millis();
}

void loop(){
  
  switch(state){
    case LISTENING:
        //in listening mode, cycle through all ports until info is received
        setChannel(listen_count);
        Serial.println(active_channel,DEC);
        startTime = millis();
        while(mySerial[active_channel-1].available() == 0 && ((millis() - startTime) < waitTime)){}
        if(mySerial[active_channel-1].available() > 0){
            state = CHANNEL_SET;
            start_lock = millis();
            Serial.println("mode: CHANNEL_SET");
        }else{
            listen_count++;
            delay(3);
        }
        if(listen_count > 4){
            listen_count = 1;
        }
        break;
    case CHANNEL_SET:
        Serial.println(active_channel);
        Serial.println(mySerial[active_channel-1].peek(),DEC);
        //delay(1);  // will need this delay when the Serial.println()'s are removed. As they are acting as the needed delay.
        if(mySerial[active_channel-1].read() == COM){
            int cnt=0;
            while(mySerial[active_channel-1].available() > 0 && cnt < MAX_BUFFER_SIZE && (uint8_t)mySerial[active_channel-1].peek() != COM){
                read_buf[cnt] = mySerial[active_channel-1].read(); //cur_read;
                cnt++;
                delay(1);
            }
            read_buf_len = cnt;
            send_msg_received();
            state = PROCESS_MSG;
            Serial.println("mode: PROCESS_MSG");
        }else{
            while(mySerial[active_channel-1].available() > 0)mySerial[active_channel-1].read();
        }
        //if a valid signal isn't received before LOCKTIME is up, the program should return to listening
        if(millis() - start_lock > LOCKTIME){ 
            state = LISTENING;
        }
        break;
    case PROCESS_MSG:
        //once the program reaches this point, it has a message
        //consisting of uint8_t values in the read_buf array
        //according to the COMMAND CODE scheme outlined above
        //if the first value in the read_buf array is greater than
        //170, then the message has reached its destination and
        //this COMMAND CODE should be executed
        
        if(read_buf[0] > ROGER){
            //execute COMMAND CODE
            switch(read_buf[0]){
                case SENDID:
                    send_ID();
                    break;
                case SETID:
                    set_ID();
                    break;
                case SETNEIGHBORS:
                    set_neighbors();
                    break;
                case AUTO:
                    state = AUTO;
                    break;
                default:
                    state = LISTENING;
                    break;
            }
        }else{
            //pass the message onto the next board
            int send_status = -1;
            int port = isvalueinarray(read_buf[0], port_map, 4) + 1;
            setChannel(port);
            for(int i=0;i<read_buf_len;i++){
              write_buf[i] = read_buf[i+1];
              write_buf_len = read_buf_len-1;
            }
            send_status = send_msg();
            if(send_status != 0){
              //something went wrong with board to board comms
              Serial.print("Error: status code = ");
              Serial.print(send_status);
              Serial.println(". Something went wrong with board-to-board comms!!!");
            }else{
              state = LISTENING;
            }
        }
        break;
    case SETNEIGHBORS:
      break;
    case AUTO:
      Serial.println("Autonomous mode active!");
      //when this signal is received this board should:
      // 1. indicate that it is waiting to be stepped on
      // 2. select the next tile from it's available neighbors, excluding the neighbor from which the signal was first received
      // 3. when stepped on:
      //   A. Indicate that it senses the child by playing the sound file and flashing lights
      //   B. Send the AUTO signal on to the next board
      //   C. Return to the LISTENING state
      if(sensor_flag == 1){
        blink_led(LEDPIN);
        if(millis() - playback_started > PLAYTIME){
          //send the AUTO message to the next board
          write_buf[0] = AUTO;
          write_buf_len = 1;
          send_msg();
          sensor_flag = 0;
          next_list_len = 0;
          auto_setup = 0;
          digitalWrite(LEDPIN, LOW);
          state = LISTENING;
        } 
      }else{
        //select the next tile
        //create an array of potential next tiles indicated by the respective port number or channel
        if(auto_setup == 0){
          for(int i=0;i<4;i++){
            if((i+1 != active_channel) && (port_map[i] < 255) && (port_map[i] > 0)){
              next_list[next_list_len] = i+1;
              next_list_len++;
            }
          }
          //if this tile is a dead-end, the result of setChannel will be to not change the active channel.
          //this means the next tile will be the tile from which the AUTO signal was originally received
          //this is the correct behavior, even though it was not explicitly programmed
          setChannel(next_list[random(next_list_len)]);
          auto_setup = 1;
        }
        // indicate that it is waiting to be stepped on and wait for sensor input
        digitalWrite(LEDPIN, HIGH); 
        if(analogRead(SENSORPIN) < sensorThreshold){
          //tile has been stepped on
          sensor_flag = 1;
          startPlayback(happy_data, sizeof(happy_data));
          playback_started = millis();
        }
      }
      break;
    default:
      break;
  }
}
